0
私は角度jで新しいです。AngularJS:コンパイル機能は何ですか
ちょうど彼らが何のようにいくつかの行を知りたいのです。
app.directive('fancybox', function($compile) {
return {
restrict: 'A',
replace: false,
link: function($scope, element, attrs) {
$scope.open_fancybox = function() {
var el = angular.element(element.html()),
compiled = $compile(el);
$.fancybox.open(el);
compiled($scope);
};
}
};
});
以下の行は明確ではありません。
var el = angular.element(element.html()),
compiled = $compile(el);
$.fancybox.open(el);
compiled($scope);
1)$ compileは何を行い、コンパイル後に何を返しますか? 2)コンパイル($ scope)のようなスコープをコンパイルする必要があるとき。
私はこの行をコメントしたかどうかテストしました($ scope);価値は表現に入れない.......なぜ?
私を詳細に案内してください。お礼
詳細:[このセクション](https://docs.angularjs.org/api/ng/service/$compile#example)を1行ずつ参照してください。この[plunker](https://plnkr.co/edit/?p=preview)を参照し、コメントを特別に読んでください。 – anoop