spring - AngularJs watch angular.element -
i'm trying integrate angularjs legacy spring mvc application because there lots of spaghetti javascript code (a huge mess!) hide / show html elements based on conditions etc.
it uses jsp , lots of custom jsp tags , because way written i'm hesitant mess jsp tags themselves.
i'm trying read values of spring input angular scope , once have can use angular hide / show stuff.
assume html
<div ng-app ng-controller="fooctrl"> backbone <input type="radio" name="yes" value="backbone"/> angular <input type="radio" name="yes" value="angular" /> </div>
i'm able read these elements angular's scope this
$scope.elements = angular.element("input[name='yes']");
but change value of these elements not getting triggered or watched angular.
ideally when radio button gets checked model change. how can this?
thank in advance.
here plnkr basic setup. http://plnkr.co/edit/crpbff9fagivbra8osdz?p=preview
one thing in controller had:
$scope.$watch('$scope.elements',function(newvalue){ console.log(newvalue); },true);
it should 'elements'
rather '$scope.elements'
. i'm not quite sure if $watch or $watchcollection going best bet here. tried having issues.
here idea:
var app = angular.module('myapp',[]); app.controller('fooctrl', function($scope){ $scope.message = "hi"; $scope.elements = angular.element("input[name='yes']"); angular.element("input[name='yes']").bind("input change", function(e) { console.log(e); });
});
Comments
Post a Comment