javascript - Angular JS $interpolate query -
javascript - Angular JS $interpolate query -
i newbie angular js , way trying understand directive functionality written below
function mydirective($interpolate, $compile) { homecoming { restrict: 'e', scope: { mycontent: '=', myurls: '=', mydata: '@' }, replace: true, template: '<div ng-bind-html="html"></div>', link: function ($scope, element, attrs) { $scope.$watch('mycontent', function (value) { var html = $interpolate(value)($scope); element.html(html); $compile(element.contents())($scope); }); } } } i not able understand next above.
1) $interpolate(value)($scope) ? sec argument $scope.
2) $compile function doing ?
3) div ng-bind-html="html" in template ?
what $interpolate(value)($scope) do?
gets literal value of value variable
what sec argument $scope.
it provides context data-binding
it('should interpolate undefined context', inject( function($interpolate) { expect($interpolate("hello, world!{{bloop}}")()).tobe("hello, world!") } )); what $compile function doing?
it converts string angular markup
div ng-bind-html="html" in template do?
it compiles html string within $scope.html , adds markup
references
angularjs guide: scope watch depths
angularjs source: interpolatespec.js
angularjs look security internals
difference in $interpolate between angularjs 1.0 , 1.2
javascript angularjs
Comments
Post a Comment