AngularJs add item to Array
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.exampleArray = ['Mango','Banana']; $scope.pushInArray = function() { // get the input value var inputVal = $scope.arrInput; $scope.exampleArray.push(inputVal); }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> Enter a value and click "Push" Button to insert in array. <input type="text" name="arrExample" ng-model="arrInput"><br> <button ng-click='pushInArray()' >Push</button><br> Array = {{exampleArray}}<br> </div> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.exampleArray = ['Mango','Banana']; $scope.pushInArray = function() { // get the input value var inputVal = $scope.arrInput; $scope.exampleArray.push(inputVal); }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> Enter a value and click "Push" Button to insert in array. <input type="text" name="arrExample" ng-model="arrInput"><br> <button ng-click='pushInArray()' >Push</button><br> Array = {{exampleArray}}<br> </div> </div> </body> </html>
Copyrights@tutorialsplane.com