javascript - Making my own filter not working -


i trying make own filter in angularjs, way wrong guess. not able left here , need update.

any 1 me fix this?, guess need convert filter service? if correct way this?

my js :

angular.module('myapp', []) angular.module('myapp.filters', []) .filter('capitalize', function(capitalize) {     return function(input) {     if (input)     return input[0].touppercase() +     input.slice(1);     } }); 

html:

<div ng-app="myapp">   {{ "san francisco cloudy" | lowercase | capitalize  }} </div> 

demo

your filter has 1 issue, not sure if that's meant - in function have function(capitalize) makes angular believe have service/factory of name. if that's have somewhere fine, doesn't seem you're using it.

you can open dev console , see if see errors - guess will.

removing makes work:

myapp.filter('capitalize', function() {     return function(input) {         if (input)             return input[0].touppercase() + input.slice(1);     } }); 

fiddle


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -