angularjs - How to call a JavaScript function from an Angular controller? -



angularjs - How to call a JavaScript function from an Angular controller? -

how can phone call shownotification() js function angular controller? because using plugin contains code in js file only.

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 auto close notification. message close after 2 seconds", autoclose: true, duration: 2 } //this js function } }). error(function(data, status, headers, config) { console.log("login failed"); shownotification(){ message: "this auto close notification. message close after 2 seconds", autoclose: true, duration: 2 } //this js function }); });

my js function in separate js file

function shownotification(params){ // function logic }

just include plugin's javascript files, should work.

to right way, best wrap plugin in angularjs service or directive.

angularjs angularjs-scope

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -