pbastowski / angular2-now

Angular 2 @Component syntax for Angular 1 apps
MIT License
145 stars 15 forks source link

Filter in Angular #15

Closed tinocencio closed 9 years ago

tinocencio commented 9 years ago

Hi, I'm trying to get Angular 1 directives to get processed with angular2now but I'm unable to get them running.

My filter is defined as this

var {SetModule, Filter} = angular2now; SetModule('App'); @Filter('currencyFilters') export class CurrencyFilters { constructor() { return function(input) { var ret=(input)?input.toString().trim().replace(",","."):null; return parseFloat(ret); }; } }

After i make an import through from filter and finally introduce this in html:

but filter is not processed. And obtain an error: Error: [$injector:unpr] http://errors.angularjs.org/1.3.17/$injector/unpr?p0=currencyFiltersFilterProvider%20%3C-urrencyFiltersFilter Any hint on how to achieve it?
pbastowski commented 9 years ago

Your filter definition is fine, but have you:

Have a look at the example below, which uses your filter and actually works.

http://jsbin.com/tipeqa/14/edit?html,js,output

The example is a bit long, because I just plugged your filter code into something else that I was working on, but if you look for currencyFilters you will find your code.

Hopefully the example helps you.

pbastowski commented 9 years ago

@tinicencio Did my explanation help you?

pbastowski commented 9 years ago

Closing, as this is not a problem with angular2now.