-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playground): add more examples with new features, like one way b…
…inding etc
- Loading branch information
Showing
7 changed files
with
174 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, Input, Output, Attr } from 'ng-metadata/core'; | ||
|
||
@Component({ | ||
selector:'my-tester', | ||
template:` | ||
<h4>Tester Cmp</h4> | ||
<pre> | ||
{{ $ctrl.inOne | json }} | ||
{{ $ctrl.outOne | json }} | ||
{{ $ctrl.attrOne | json }} | ||
</pre> | ||
<button ng-click="$ctrl.outOne();$event.stopPropagation();">exec outOne</button> | ||
<hr> | ||
<ng-transclude></ng-transclude> | ||
<div> | ||
<input type="text" ng-model="$ctrl.twoWay"> | ||
<code>{{ $ctrl.twoWay }}</code> | ||
</div> | ||
`, | ||
legacy:{transclude:true} | ||
}) | ||
export class TesterComponent{ | ||
@Input() twoWay; | ||
@Input() inOne = { name:'Martin' }; | ||
@Output() outOne = ()=>{ console.log( 'boooo' );}; | ||
@Attr() attrOne = 'hello default'; | ||
|
||
constructor(){ | ||
console.log( '===Tester CMP ctor====' ); | ||
console.log( this.outOne.toString() ); | ||
console.log( angular.toJson( this, true ) ); | ||
} | ||
|
||
ngOnInit(){ | ||
console.log( '===Tester CMP, OnInit====' ); | ||
console.log( this.outOne.toString() ); | ||
console.log( angular.toJson(this,true) ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Directive, Input, Output, Attr, HostListener } from 'ng-metadata/core'; | ||
|
||
@Directive({ | ||
selector:'[my-tester-attr]', | ||
}) | ||
export class TesterAttrDirective{ | ||
@Input() inOne = { name:'Martin from directive' }; | ||
@Output() outOne = ()=>{ console.log( 'mooo from directive' ) }; | ||
// @Output() outOne: Function; | ||
@Attr() attrOne = 'hello default from directive'; | ||
|
||
constructor(){ | ||
console.log( '===Tester DIR, ctor====' ); | ||
console.log( this.outOne.toString() ); | ||
console.log( angular.toJson(this,true) ); | ||
} | ||
|
||
ngOnInit(){ | ||
console.log( '===Tester DIR, OnInit====' ); | ||
console.log( this.outOne.toString() ); | ||
console.log( angular.toJson(this,true) ); | ||
} | ||
|
||
@HostListener('click') | ||
onClick(){ | ||
console.log( 'onClick called!', this ); | ||
this.outOne(); | ||
} | ||
} |