如何從角度控制器調用showNotification()
JS函數?這是因爲我正在使用一些只包含該JS文件中的代碼的插件。如何從Angular控制器調用JavaScript函數?
authentication.controller('loginController', function($scope , $http) {
$http({
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
data: $.param(($scope.loginData)),
}).success(function(data, status, headers, config)
{
if(data.status == "success"){
}
else
{
alert("invalid credentials");
showNotification(){
message: "This is Auto Close notification. Message will close after 2 seconds",
autoClose: true,
duration: 2
} //THIS IS JS FUNCTION
}
}).
error(function(data, status, headers, config) {
console.log("Login failed");
showNotification(){
message: "This is Auto Close notification. Message will close after 2 seconds",
autoClose: true,
duration: 2
} //THIS IS JS FUNCTION
});
});
我在不同的JS文件JS功能
function showNotification(params){
// Function Logic
}
您是否在角度文件之前附加了外部js文件? – 2014-10-30 08:47:26
yes ofcourse。我已經包含那個包含示例()函數 – 2014-10-30 08:49:24
的JS文件,我不明白你的函數的調用!你把參數在身體看看http://stackoverflow.com/questions/26628619/angular-js-dependency-injection-in-global-function – Whisher 2014-10-30 09:07:35