У меня есть этот шаблон HTML в fileA.directive.html :
<md-button ng-click="resetForm()" class="btn btn-primary">Reset form</md-button>
<user-form reset-user-fn=""></user-form>
И в мой fileA.directive.js :
app.directive("shopAppFormCustomer", function() {
return {
restrict: "E",
replace: true,
templateUrl: "fileA.directive.html",
scope: {},
controller: [
"$scope",
function($scope) {
$scope.resetForm = function () {
// want to call reset-user-fn here
}
}
]
};
})
В мой fileB.directive.js у меня есть директива userForm
app.directive("userForm", function() {
return {
restrict: "E",
replace: true,
templateUrl: "fileB.directive.html",
scope: {resetUserFn: "=" },
controller: [
"$scope",
function ($scope) {
$scope.resetUserFn = function () {
// reset goes here
}
}
]
}
Вот мой вопрос:
Как я могу вызвать атрибутresetUserFn
в мой файл B.directive.js в мой файл A.directive.js?
Любой источник или документация, пожалуйста.
Примечание: Я не буду использовать пользовательское событие, если это возможно.