Reputation: 53
For example, Then I reset the input value via jQuery like: $('#example').val(''); But the value of angular model "Something" won't change. How to solve this trouble pleases!!!
Upvotes: 0
Views: 1241
Reputation: 136174
If you're using Angular, then do it in Angular way.
I believe you shouldn't use jQuery to bind AngularJS scope variable. On input element you must use ng-model
directive that will take care about angular two way binding.
HTML
<div ng-app="app" ng-controller="mainCtrl">
<input id="sampleInput" ng-model="testInput"/>
Below you can get updated value of scope variable.
{{testInput}}
<button ng-click="click()"></button>
</div>
JS CODE
angular.module('app',[])
.controller('mainCtrl', [ '$scope', function($scope) {
$scope.click = function(){
console.log($scope.testInput); //here is updated scope variable inside controller
};
}]);
Thanks.
Upvotes: 1