0
master.html 파일에 header.html을 동적으로 포함하는 지시문을 만들었습니다.angularjs 지시문 범위 기능이 작동하지 않음
는
var app = angular.module('plunker', []);
app.directive('header', function() {
var directive = {};
directive.restrict = 'AE';
directive.replace = true;
directive.scope = {};
directive.templateUrl = "header.html";
directive.link = function postLink($scope, $element, $attrs, $resource) {
$scope.version = "1.1.1.1";
$scope.getusername = function() {
$scope.username = "pals";
};
};
return directive;
});
HEADER.html 현재를 http://plnkr.co/edit/Iau6Fu?p=preview
범위 변수 ($ scope.version)가 작동 중이 @ 작성
<div ng-init="getusername()">
<p>
This part of the hader is always here
</p>
<p>
User {{username}} is logged in :D
</p>
<p>
{{version}}
</p>
</div>
전체 코드를 app.js.
그러나 scope function call ($ scope.getusername)이 발생하지 않습니다.
모든 조언을 주시면 감사하겠습니다. 감사.