1
我在外部JavaScript類中有一個方法,我試圖調用裏面的方法來調用我的控制器函數(在我的視圖中有一個切換按鈕,當切換爲checked
時,我想調用外部方法)如何將外部類調用到AngularJS控制器中
控制器
myApp.factory('PushClient', ['', function() {
return PushClient;
}]);
myApp.controller('MainController', function (PushClient,$scope, $rootScope, $http, $window){
$rootScope.toggleSelection = function toggleSelection(event) {
if(event.target.checked){
var PushClient = new PushClient();
PushClient.mypush();
}else {
}
};
}
外部PushClient類
class PushClient {
constructor(....){...}
............
mypush(){
alert("hiiii");
}
}
在這裏看到https://開頭developer.mozilla.org/ EN /文檔/網絡/的JavaScript /參考/班 – gdmanandamohon