我有这样的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
到我fileB.directive.js到我fileA.directive.js?
所有源代码或文档请。
注:我不会使用自定义事件,如果有可能。