Skip to content

Commit

Permalink
feat(playground): add example for injecting same type of local direct…
Browse files Browse the repository at this point in the history
…ives with separate accessors
  • Loading branch information
Hotell committed Mar 2, 2016
1 parent f39bbc4 commit 01a91d7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions playground/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { TodoStore } from './stores/todoStore.service';
import { ElementReadyDirective } from './directives/element-ready.directive';
import { MyValidatorDirective } from './directives/my-validator.directive';
import { MyFooDirective } from './directives/my-foo.directive';
import { MyFormBridgeDirective } from './directives/my-form-bridge.directive';

export const AppModule = angular.module( 'app', [TabsModule] )

Expand All @@ -25,5 +26,6 @@ export const AppModule = angular.module( 'app', [TabsModule] )
.directive( ...provide( ElementReadyDirective ) )
.directive( ...provide( MyValidatorDirective ) )
.directive( ...provide( MyFooDirective ) )
.directive( ...provide( MyFormBridgeDirective ) )

;
25 changes: 23 additions & 2 deletions playground/app/components/todo-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ <h3>Todo List remaining: {{ $ctrl.todos | remainingTodos }}</h3>

<button
class="mdl-button mdl-js-button mdl-button--accent"
ng-click="$ctrl.showQueryExample=!$ctrl.showQueryExample">{{ $ctrl.showQueryExample ? 'hide' : 'show'}} <code>@Query</code> decorators example
ng-click="$ctrl.showQueryExample=!$ctrl.showQueryExample">
{{ $ctrl.showQueryExample ? 'hide' : 'show'}} <code>@Query</code> decorators example
</button>
<div ng-if="$ctrl.showQueryExample">
<h3>check your console logs mate!</h3>
Expand All @@ -41,7 +42,8 @@ <h3>check your console logs mate!</h3>

<button
class="mdl-button mdl-js-button mdl-button--accent"
ng-click="$ctrl.showDirectiveDiExample=!$ctrl.showDirectiveDiExample">{{ $ctrl.showDirectiveDiExample ? 'hide' : 'show'}} <code>@Inject</code> directive
ng-click="$ctrl.showDirectiveDiExample=!$ctrl.showDirectiveDiExample">
{{ $ctrl.showDirectiveDiExample ? 'hide' : 'show'}} <code>@Inject</code> directive
</button>
<div ng-if="$ctrl.showDirectiveDiExample">

Expand All @@ -54,3 +56,22 @@ <h3>check your console logs mate!</h3>
</form>

</div>

<button
class="mdl-button mdl-js-button mdl-button--accent"
ng-click="$ctrl.showSameLocalDiExample=!$ctrl.showSameLocalDiExample">
{{ $ctrl.showSameLocalDiExample ? 'hide' : 'show'}} <code>multi equal @Inject</code> directive
</button>
<div ng-if="$ctrl.showSameLocalDiExample">

<form name="diParentForm">
Inside ParentForm
<div ng-form="diChildForm" my-form-bridge>
Inside childForm
</div>

<button>submit or so</button>

</form>

</div>
14 changes: 14 additions & 0 deletions playground/app/directives/my-form-bridge.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Directive, Inject, Self, SkipSelf } from 'ng-metadata/core';

@Directive( { selector: '[my-form-bridge]' } )
export class MyFormBridgeDirective {
constructor(
@Inject( 'form' ) @Self() private form: ng.IFormController,
@Inject( 'form' ) @SkipSelf() private parentForm: ng.IFormController
) {}

ngOnInit(){
console.log( this );
}

}

0 comments on commit 01a91d7

Please sign in to comment.