It won't be truly 'global' in the static sense, but you can always register 
your function as a singleton into your module to be injectable into any 
controller.

myModule.factory('isEmptyString', function() {

    var _isEmptyString = function(str) {
        //whatever your logic is here
    };

    return _isEmptyString;
});

Then you can inject your function into your controllers, services, etc like:

function SomeController($scope, isEmptyString){

     ...

     isEmptyString(myVar);

     ...
}



On Friday, April 27, 2012 7:47:33 AM UTC-4, Freewind wrote:
>
> I want to define some util functions like 
> "isEmptyString"/"checkEmptyJson()" and so on.
>
> In normal js, I will create a util.js, and put them there. 
>
> What to do the same in angularjs? Is there any special support(or 
> requirement) I should notice?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to