Here its my html code
<!DOCTYPE html> <html> <head> <title></title> </head> <body ng-app="chat"> <div ng-controller="chatCtrl"> <div ng-repeat="i in chatResult"> {{i.first_name}} {{i.last_name}} {{i.id}} {{i.age}} </div> <input type="text" ng-model="message">{{message}} <input type="text" ng-model="username">{{username}} <button ng-click="saveData()">Submit</button> </div> <script src="static/jquery.js"></script> <script src="static/angular.min.js"></script> <script src="static/app.js"></script> </body> </html> In above html code when I'm press submit button ng-click function not respond.
here its my app.js
var chat = angular.module('chat', []) chat.controller('chatCtrl', function($scope,$http){ $scope.chatResult = null; $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencsoded"; $http.get('http://localhost:3000/chat').success(function(result){ $scope.chatResult = result; }); $scope.message = ''; $scope.username = ''; $scope.saveData = function(){ $console.log('save data function'); $http.post('http://localhost:3000/save/chat/data', {message:$scope.message, username:$scope.username}). success(function(result){ $console.log(result); }); } }); When the submit button is clicked, I call an angular click event to trigger the saveData function.
but it's not working in my case any problem in my code...
type="button"to your button tag