angular.js - How to get the data-bound value immediately in angularJs?
伊谢尔伦
伊谢尔伦 2017-05-15 16:54:01
0
2
737

I want to use the data-bound value immediately:

Get data from Json file and bind it to scope
$scope.abc="hahahah";

<

p class="***" data-value="{{abc}}" skilldetail='' index='0'>
But when getting the data-value from the link function of the directive, I did not get "hahahah", but got {{abc}}

The value of element.find('.***').attr('data-value'); is {{abc}}, not hahahah.

How to do this? When does the value of ng-bing take effect?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
Ty80

$scope.apply() tells angular that it’s time to update the data

滿天的星座
js...

link: function(scope, el, attrs) {
    ...
    scope.$apply(function() {
        // TODO
    });
    ...
}
...
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template