adding data using angular

by shushanth pallegar

HTML

<div ng-app="myApp">
    
    <div ng-controller="myCtrl">
    <input type="text" ng-model="data"/>
    <button ng-click="addIt()">Add !!!</button>
        <p>{{dataInserted}}</p>
    </div>
    
</div>

JavaScript

var app = angular.module('myApp',[]);

app.controller('myCtrl',myCtrl);

myCtrl.$inject = ["$scope"];

function myCtrl($scope){
    
    $scope.dataInserted = [];
    
    $scope.addIt=function(){
        angular.forEach($scope.data,function(key,value){
            
            $scope.dataInserted.push(key +":"+ value);
        });

      }

}