angularjs - Changing the value of ng-model bound html element using jquery -
i have long form select boxes, text , number type input etc. wish when user clicks submit button of form, check fields empty , fill fields dummy values when read values correct scope vars values.
i checking if fields empty using jquery , populate fields using jquery.
what happens though fields populated, scope vars value not change...how change this???
here fiddle:link
what want here on clicking 'click', input reads bhumiak, should <h1>hello {{yourname}}!</h1>
how this?
yes, lucuma mentioned, shouldn't jquery instead angular way.
angular can fill output string no additional code, this:
<div ng-app="myapp" ng-controller="myctrl"> <label>name:</label> <input type="text" id="na" ng-model="yourname" placeholder="enter name here"/> <input type="button" value="click" ng-click="myclick()"/> <h1>hello {{yourname}}!</h1> </div>
look fiddle, made example: http://jsfiddle.net/marcorinck/zyylf/
yes, can use call $apply when needed (especially in directives) first should give $apply function parameter , second should make changes in function angularjs can pick up.
for further explanations $apply have blog post: http://jimhoskins.com/2012/12/17/angularjs-and-apply.html
Comments
Post a Comment