As explained in another answer, watched expressions are evaluated on every digest and the resulting value is compared to their previous value - dirty checking. If there is a change, another iteration of the digest starts because a change in one value might cause a change in another.
If there is a circular dependency (including, the circle of one, i.e. the same expression is different every time), it results in an infinite loop that Angular stops after 10 iterations.
Specifically, your getLink
function's return value is a promise (the return value of $http), and Angular bindings do not "wait" on a promise.
What you want to do is to kick start the $http
call and in its handler assign the return value to a ViewModel property that would be bound to <a>
:
function getLink(){
$http.get(inputUrl)
.success(function(data){
$scope.url = data.data;
});
}
You can call getLink
, for example, when your controller runs.
In the View you just bind url
to ng-href
(not href
) attribute:
<a ng-href="url">My Link</a>
$http
. To save confusion for people searching for this error in the future, it's best if you try to come up with another way to solve your specific problem, and if you still encounter errors, post a new question. Trying to update the question to get different answers only creates confusion.