Skip to content

Commit

Permalink
feat(playground): use new injection by type via reflect-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell committed Apr 10, 2016
1 parent 000553d commit 088ca11
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions playground/app/components/todo-app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ export class TodoAppCmp{
todos: TodoModel[];

constructor(
@Inject(TodoStore) private todoStore: TodoStore
private todoStore: TodoStore
) {

this.todos = this.todoStore.todos;
}

Expand Down Expand Up @@ -103,3 +102,5 @@ export class TodoAppCmp{


}

console.dir(TodoAppCmp)
9 changes: 5 additions & 4 deletions playground/app/directives/my-foo.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { forwardRef, Directive, Inject, Host, Self, Optional, OnInit, AfterContentInit } from 'ng-metadata/core';
import { NgModel, NgForm } from 'ng-metadata/common';
import { MyValidatorDirective } from './my-validator.directive';
import {TodoStore} from '../stores/todoStore.service';

Expand All @@ -12,10 +13,10 @@ export class MyFooDirective implements OnInit,AfterContentInit{
};

constructor(
@Inject('ngModel') @Host() private ngModelCtrl: ng.INgModelController,
@Inject( forwardRef(()=>MyValidatorDirective) ) @Self() private myValidator,
@Inject('form') @Optional() @Self() private FormCtrl: ng.IFormController,
@Inject( TodoStore ) private todoSvc
@Host() private ngModelCtrl: NgModel,
@Inject( forwardRef(()=>MyValidatorDirective) ) @Self() private myValidator: MyValidatorDirective,
@Optional() @Self() private FormCtrl: NgForm,
private todoSvc: TodoStore
){}

ngOnInit(){
Expand Down
1 change: 1 addition & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="style.css">
<script src="../node_modules/systemjs/dist/system.js"></script>
<script src="../node_modules/reflect-metadata/Reflect.js"></script>
<script>
System.config( {
baseURL: '/',
Expand Down
4 changes: 3 additions & 1 deletion playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"pretty": true
},
"files": [
"app/main.ts",
Expand Down

0 comments on commit 088ca11

Please sign in to comment.