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?

2

1 Answer 1

1

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

       $scope.loadInputs=function()
       {
             $scope.contact_name='test';
       };
Sign up to request clarification or add additional context in comments.

1 Comment

Worked like a charm. Can't believe it was this simple. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.