ngParty / ng-metadata

Angular 2 decorators and utils for Angular 1.x

Home Page:https://hotell.gitbooks.io/ng-metadata/content/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

adding a new property to @Component decorator

ciel opened this issue · comments

commented

I'm trying to use angular-css to add scoped component css to a project using ng-metadata, but I'm hitting a wall.

angular-css needs a string | string[] property on the component initialization. Like so;

{ 
   selector: 'divNg',
   templateUrl: 'tmpl.html',
   css: 'styles.css'
}

This is proving troublesome because the @Component decorator doesn't allow this property. Is there any way around this?

I'm not 100% sure of this. But angular2 has a style property for components. I never tried to use it with angular2 or ng-metadata. But maybe it already works with ng-metadata like with angular2. If not the angular2 syntax should be used and then angular-css should not be needed anymore.

commented

The styles property from ng-metadata does nothing for components that I can tell. It's purely there to conform to the angular 2 spec. I dove deep into the code and could also find no evidence that it does anything.

I wonder if the legacy option passes through the options to the directive configuration. I would assume not but it is worth a try.

{ 
   selector: 'divNg',
   templateUrl: 'tmpl.html',
   legacy: {
       css: 'styles.css'
    }
}
commented

I know you can get the metadata pretty easily. I think they'd be open to a PR assuming it doesn't cause build problems for other people.