Reputation: 23
Using AngularJS, how can I use a Filter (as out of the box feature) to support "String Processing" on "View Level"? knowing that implied JS function (that will implement such string processing) is under a common module & reusable from the whole AngulaJS application (i.e. can be recalled from any view under any module).
Upvotes: 0
Views: 388
Reputation: 1955
The short answer is Injection based on what version of angular you are using. You should show your code or create a public repo for us to help you. Here is a shot in the dark!... You want to create your filters at the app level and inject them into whatever controller you want to use them in.
example:
app.filter('upper', function () {
return function (input) {
return input.toUpperCase();
};
});
Then in view1.js do this:
.controller('view1', ['$scope','upper', function($scope, upper) {
var message = 'this is just an example';
}
and in your view do something like this:
<h1>{{message | upper}}
That should display : THIS IS JUST AN EXAMPLE
Upvotes: 1