?
Solved

angular adding row after adding value from jquery

Posted on 2015-01-14
4
Medium Priority
?
176 Views
Last Modified: 2015-01-15
http://plnkr.co/edit/QZymHM?p=preview

Ok the problem I am having is I can type inside the text box the click add and it add the value to the table row. The problem is I am using jquery to add the value but angular directive does not detect this.
the class shows (( ng-valid ng-dirty ng-touched )) but if I enter some value I see (( ng-valid ng-dirty ng-touched )) how can i tell angular there is a value there??
0
Comment
Question by:Seven price
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 2000 total points
ID: 40550887
It is really not a good idea to use jQuery to mess with data when using angularJS. Let aJS manage the bindings and everything and use jQ only for UI effects. In the rare cases when you really must, you can access the Controllers scope from outside.

Also, it would increase encapsulation (in such cases) if you rather expose a method like setPerson(firstN, lastN) so that you don't have to access $scope.firstname etc.

    var scope = angular.element($("#cotroller")).scope();
    scope.$apply(function(){
        scope.firstname = 'john';
        scope.lastname = 'Doe';
    });

Open in new window


Check plunkr: http://plnkr.co/edit/UByO9PFpxYC9jMG4VFI8?p=preview
0
 
LVL 9

Author Comment

by:Seven price
ID: 40551182
your example does not seem to work?
0
 
LVL 22

Expert Comment

by:ambience
ID: 40551197
This happened to me twice - plunkr not getting saved. Check again.

I just added id="controller" to the DIV with ng-controller attrib.
0
 
LVL 9

Author Closing Comment

by:Seven price
ID: 40551235
thanks for the wisdom
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question