search

Home  >  Q&A  >  body text

angular.js - How to use angular core components in a custom function?

var app = angular.module('controllers', []);
app.controller('StoreSignUpCtrl', function($scope, $state, $q){});

You can inject these system components and use them by referencing $scope, $state, $q, $ionicActionSheet in the controller.
How can I use these components if I customize a function?

var myFun = function($q){};
阿神阿神2871 days ago620

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-15 16:54:33

    Your functions all appear in a controller or instruction or a service or block in Angular, and all of the above can be imported into Angular's internal library, so the functions you define can definitely be used,

    For example, you have to define the function in a directive

    angular.module('controllers', []).directive('mydirective',['$timeout',function($t){
        var myFun = function($t){};//这样就可以用到 系统的组件$timeout了 
    }])
    

    If you don’t understand anything, you can continue discussing

    (I’m not sure where the function you defined is, so the answer may not be what you want)

    reply
    0
  • Cancelreply