2
에서 지시 함수를 호출하는 자바 스크립트 기능 :방법 자바 스크립트
var API = (function(){
return {
function invokeDirective(){
invvoke();
$scope.setItem() // to directive
}
}
});
지침 :
angular.module('sampleComponents', ['$strap.directives']).directive('titlebar',
function($filter,$timeout)
{
return {
restrict: 'AE',
replace: true,
scope: true,
transclude: true,
template: '<div class="searchBar r etc ........',
controller: function($scope,$http,$timeout)
{
$scope.setItem = function(){
// want to invoke this function from api.js -
}
}
link: function(scope, element, attrs){
// etc:
}
});
가 어떻게 api.js
에서 $scope.setItem
를 호출 할 수 있습니다? 가능한가? 제발 제안 해주세요.
API.js 자체가 의존 서비스로 지시문에 삽입 된 각도 서비스 여야합니다. 그런 다음 필요한 경우 외부 API를 통해 서비스 호출을 노출해야합니다. – CodingIntrigue