0

I'm relatively new to Angular, and suspect I am not grasping a concept.

What I want to do: Load main view. Click a button on main view which loads a different view. Use jQuery (or any other method) to return an input field in that new view, so I can change the text of the input.

Angular view, which loads after I click a button in the main view:

<input type="text" id="contact_name" ng-model="contact_name"></input>

Function that is supposed to change the text of the input field

function loadInputs(){
    $('#contact_name').val('test'));
}

What I tried so far, both of these are being called from the controller:

$scope.$on('$routeChangeSuccess', function () {
  loadInputs();
});

and

$scope.$on('$viewContentLoaded', tempContact.loadInputs());

Neither of which worked. What is the "angular way" of doing this?

Kahtaf Alam
  • 463
  • 2
  • 7
  • 19
  • The angular is not to use jquery selectors and just use the mvvm pattern. `$scope.contact_nam='test'` – Jayantha Lal Sirisena Dec 23 '13 at 06:46
  • Read [How do I “think in AngularJS” if I have a jQuery background?](http://stackoverflow.com/questions/14994391/how-do-i-think-in-angularjs-if-i-have-a-jquery-background?rq=1). – Stewie Dec 23 '13 at 09:30

1 Answers1

1

I suggest you that do not implement this with jQuery. Just modify your code slightly.

       $scope.loadInputs=function()
       {
             $scope.contact_name='test';
       };
Hearaman
  • 8,466
  • 13
  • 41
  • 58