中链接选项的意义是什么我正在学习角度和一段时间绊倒了解代码及其意义。请参阅下面的示例代码并告诉我指令中的链接选项是什么?Angular:在指令
什么样的目的链接选项解决或做什么?当链接选项中的代码激发?请给我一些关于链接选项的见解。谢谢
var myApp = angular.module('myApp', []);
myApp.directive('ngFinishRender', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attr) {
if (scope.$last === true) {
$timeout(function() {
scope.$eval(attr.ngFinishRender);
}, 0);
}
}
}
});
myApp.controller('myController', function ($scope, $timeout) {
$scope.lists = [
{ name: 'A', isShow: true },
{ name: 'B', isShow: true },
{ name: 'C', isShow: false },
{ name: 'D', isShow: false },
{ name: 'E', isShow: true },
{ name: 'F', isShow: true },
];
$timeout(function() {
$scope.lists[2].isShow = true;
}, 3000);
$timeout(function() {
$scope.lists[3].isShow = true;
}, 6000);
$scope.finish = function() {
console.log('finish');
}
});
请仔细阅读关于Angular指令的文档https://docs.angularjs.org/guide/compiler – Chandermani