javascript - Get DOM element of watch event in Angular.JS -


i have 2 select boxes on web page, , when state chosen first 1 use angular load in options second. when page first loads, second select box has 1 item, select state... , after first item changed, want change select....

is possible access dom element through angular make change, or must use full-on jquery selector in example:

$scope.$watch('state', function() {     $http.get('institutions?state=' + $scope.state).success(function(institutions) {         $scope.institutionoptions = institutions;          // avoid jquery selector if possible...         $('[name=institution_id] option:first').html('select...');     }); }, true); 

i think should stick data binding as possible. bind $scope.message:

js:

$scope.message = "initial message" 

html:

<select ng-model="selected" ng-options="c.o c in options">   <option value="">{{message}}</option> </select> 

when receive data, change message:

$scope.message = "select..."; $scope.options = [{o:"option1"},{o:"option2"}, {o:"option3"} ] 

see plunker: http://plnkr.co/edit/dzc5v3tleukzhsevxibx?p=preview


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -