pbastowski / angular2-now

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

Attributes? #17

Closed ghost closed 9 years ago

ghost commented 9 years ago

How can I declare Attributes?

Does it assume a @Component is an attribute is no @View is used?

Also for directives how can I set transclude: true or require: ngModel

pbastowski commented 9 years ago

1) Attributes: @Component({ ..., bind: { myAttr: '=' } })

2) Search the README for ngmodel. There it shows you how to refer to component's controllers, including your own ngModel.

pbastowski commented 9 years ago

Also, bind takes the same syntax as scope with regular Angular 1 attributes.

ghost commented 9 years ago

I mean directives that are restrict A.

On Mon, Jul 27, 2015, 12:38 AM pbastowski notifications@github.com wrote:

Also, bind takes the same syntax as scope with regular Angular 1 attributes.

— Reply to this email directly or view it on GitHub https://github.com/pbastowski/angular2-now/issues/17#issuecomment-125111441 .

pbastowski commented 9 years ago

@robertbaker Sorry for the late reply, I was on vacation until yesterday, without my laptop or reasonable internet.

Both "E" and "A" type directives support transclusion. Just add a <content></content> block in your template's HTML where you want the transcluded content to appear and transclude will be set to true automatically for you. If using templateUrl you'll have to add the <div ng-transclude></div> yourself and pass transclude:true into the options of @View

See this https://github.com/pbastowski/angular2-now#transclude-and-contentcontent section of the README for an example.

pbastowski commented 9 years ago

I hope the question was answered adequately. I'm closing this issue.