<body> <div id='content' ng-app='MyApp' ng-controller='MainController'> <label>F name:</label> <input type="text" ng-model="FirstName"/> <br/> <label>L Name::</label> <input type="text" ng-model="LastName"/> <button ng-click="addNew()">Add New</button> </div> </body>
app.controller("MainController", function($scope) { $scope.FirstName = ""; $scope.LastName = ""; $scope.addNew = function() { console.log(FirstName); console.log(LastName); }; });
$scope.addNew = function() { // Include $scope. when accessing variables in the scope. console.log($scope.FirstName); console.log($scope.LastName); };
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)