javascript - How to call a controller function from another controller? -


What is the easiest way to call the controller's work from another controller?

I have such a controller ..

Administrator 1

  $ scope.setTitleKey = function {title} { $ Scope.currentTitleKey = titleKey; $ Scope.getDetails (); };  

Administrator 2

  $ scope.getDetails = function () {if (TitleKey! == "All") { $ Scope.bookInfo; BookDetails.getBook Title (TitleKu). Then (function (result) {$ scope.bookInfo = results.data;}, function (error) {warning (error.data.message);}); }; };  

I just want to call the function from another controller

The simple argument is that if the function with controller 1 is then another function call Controller 2

Any Idea

Factory or Service

This is the best way to get all the functions and variables you want when you want to share the code in your controller. Want share Like

  Modulename.factory ("ABC", function () {// Modulename which you have created on your code, this is just an instance of var test = 0; return {/ ** Get this test ** ** / "getABC" on this test to set the test price * ** / "set ABC": function (testest) {test = passtest;}}: function () {return exam ;}, / **});  

Now use in Controller 1

  $ scope.setTitleKey = function (title, ABC) {ABC.getABC () Do; // mill 0; ABC.setABC (5); };  

Now Administrator 2

  $ scope.getDetails = function () {ABC.getABC (); // get 5;  

Here I am sharing an argument that you can apply and it will be useful for more searching in a coonor doctor

thanks


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -