0

The script block not working in AngularJS ng-repeat section. The issue is given below.

<div ng-repeat="user in users">
  <input type="text" ng-model="{{user.mobile}}" ng-value ="{{user.mobile}}">

  <script>
    $(function () {
        var mobile ="{{user.mobile}}";
        alert("{{user.mobile}}");            
    });
 </script>
</div>
halfer
  • 19,824
  • 17
  • 99
  • 186
Anil Singh
  • 4,173
  • 4
  • 41
  • 47
  • AngularJS doesn't read hidden fields. It just ignores them. You have to put your data on the model. Also, you're using a lot of jQuery here to do things that you simply wouldn't in Angular. DOM manipulation would normally go in an Directive. You might want to start with the 'official' tutorial: https://docs.angularjs.org/tutorial/step_00, or this one: http://www.w3schools.com/angular/. If you're up for a book, this one is best imo: http://www.amazon.com/Pro-AngularJS-Experts-Voice-Development/dp/1430264489/ref=sr_1_1?s=books&ie=UTF8&qid=1432285869&sr=1-1&keywords=angularjs – jme11 May 22 '15 at 09:12
  • I have updated my code, please seen, tell me how to get the value {{user.mobile}} in my ? need to alert for all the mobile no for users collection. – Anil Singh May 22 '15 at 09:17
  • You can't. You simply can't do it that way combining Angular expression with the jQuery script on your page like that. I can show you how to do it in Angular, but I need to see your controller and more of your html to really understand what you're trying to do. – jme11 May 22 '15 at 09:39
  • using ng-init="alertFunc(user)" I can find all mobile no like.
    {{item}}
    and $scope.alertFunc = function(user){ alert(user.mobile); } but my tabs not working.
    – Anil Singh May 22 '15 at 09:42
  • I don't see any tabs in the code in your question, so I can't help. I'd be happy to, if you would provide a fiddle, a plunker or just some more code in your question. Right now though, I still can't even figure out what you're trying to do. – jme11 May 22 '15 at 09:52
  • Ok wait.., I going to setup on plunker after that i will share you. – Anil Singh May 22 '15 at 09:54

1 Answers1

1

Script-tags in AngularJS expression will not evaluate. This is also not the way you want to do this. Do this in a controller, directive, but not in your DOM.

https://groups.google.com/forum/?fromgroups#!topic/angular/9d-rhMiXDmg

cverb
  • 645
  • 6
  • 20