我们的团队正在ServiceNow中构建一个Service Portal页面,并有一个小部件可以通过ng-click打开一个Material模式窗口:
<md-button id="small-btn" class=" btn1" ng-click="showAdvanced($event)" >
<md-icon ng-if="!data.sysID" ng-style="{'background-color':'#F44336'}" class="circle-border md-60">assignment</md-icon>
<md-icon ng-if="data.sysID" ng-style="{'background-color':'#4CAF50'}" class="circle-border md-60">assignment_turned_in</md-icon>
</md-button>
ng-click功能如下所示:
$scope.showAdvanced = function(ev) {
$mdDialog.show({
controller: DialogController,
templateUrl: 'material-modal',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
preserveScope: true,
focusOnOpen: false,
scope:$scope
})
//Broadcast this function
$rootScope.$broadcast();
};
在另一个小部件中,我有和IntroJS Tour,我正在尝试实现一个完整的回调,在游览结束后打开模态窗口:
intro.oncomplete(function() {
//run the showAdvanced() function that opens the modal window from above
$rootScope.$on()
});
$ rootScope是实现此目的的最佳方式吗?如果是这样,有人可以提供一些语法建议吗?我试图在其他stackoverflow问题上关注一些例子,但似乎无法让它发挥作用。谢谢!