How can I add some small utility functions to my AngularJS application?

后端 未结 7 1759
情深已故
情深已故 2020-12-02 03:46

I would like to add some utility functions to my AngularJS application. For example:

$scope.isNotString = function (str) {
    return (typeof str !== \"strin         


        
7条回答
  •  执笔经年
    2020-12-02 04:45

    Why not use controller inheritance, all methods/properties defined in scope of HeaderCtrl are accessible in the controller inside ng-view. $scope.servHelper is accessible in all your controllers.

        angular.module('fnetApp').controller('HeaderCtrl', function ($scope, MyHelperService) {
          $scope.servHelper = MyHelperService;
        });
    
    
    

提交回复
热议问题