?
Solved

angular adding row after adding value from jquery

Posted on 2015-01-14
4
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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

777 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