문제가 있습니다. 내 index.html 페이지에 HTML 템플릿 페이지에있는 버튼을 포함 시키려고합니다. 나는 페이지가이ng-included 버튼을 클릭하십시오.
<ng-include src="'logout/logout.template.html'"></ng-include>
처럼 수행
<button type="button" class="btn btn-default btn-sm" ng-click="$ctrl.lala()">
<span class="glyphicon glyphicon-log-out" ></span> Log out
</button>
문제는, 문제는 작동하지 않습니다. ctrl 함수에 액세스하지 않습니다. 내가 읽었을 때 ng-include는 다른 각도 지시문과 잘 작동하지 않으므로 내 질문이 있습니다. 코드 템플릿을 복사하지 않고 index.html에 단추 템플릿을 포함시킬 수있는 방법은 무엇입니까? 그걸 깨뜨리지 마라.
componenent :
'use strict';
angular
.module('logout')
.component('logout', {
templateUrl: 'logout/logout.template.html',
controller: ['$scope', '$location', '$localStorage', 'Logout',
function LogoutController($scope, $location, $localStorage, Logout) {
this.lala = function() {
console.log("doing logout");
}
}
]
});
입니다. 그래서 함수'lala()'는 호출되는 범위에 존재하지 않습니다. – ksav
이것을 사용해 보셨습니까? - '
' –@NikhilNanjappa가 시도했지만 여전히 작동하지 않습니다. – Mocktheduck