1

Is there a way to tell angular that a particular function in $scope is dependant on some other fields in $scope? I would like to hide some functionality in data model, for example:

$scope.user = {
   name: "John",
   surname: "Smith",
   getUsername: function() {
      return [this.name, this.surname].join(' ');
   }
}

Then I would like to use $scope.user.getUsername() in the html template, but when I change $scope.user.name, template doesn't refresh. Is the a way to tell angular that this function is dependant on other fields?

1 Answer 1

1

Ok, It turned out that Angular is doing it automatically but I was changing it it without using $apply.

Sign up to request clarification or add additional context in comments.

Comments

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.