fix(ivy): Update Todo app to take advantage of optional injector (#23345)
PR Close #23345
This commit is contained in:
parent
4384a92271
commit
f4017ce5e3
|
@ -1,4 +1,7 @@
|
|||
[
|
||||
{
|
||||
"name": "BLOOM_SIZE"
|
||||
},
|
||||
{
|
||||
"name": "CIRCULAR$2"
|
||||
},
|
||||
|
@ -29,6 +32,12 @@
|
|||
{
|
||||
"name": "IterableChangeRecord_"
|
||||
},
|
||||
{
|
||||
"name": "IterableDiffers"
|
||||
},
|
||||
{
|
||||
"name": "NG_ELEMENT_ID"
|
||||
},
|
||||
{
|
||||
"name": "NG_HOST_SYMBOL"
|
||||
},
|
||||
|
@ -176,6 +185,9 @@
|
|||
{
|
||||
"name": "_c9"
|
||||
},
|
||||
{
|
||||
"name": "_currentInjector"
|
||||
},
|
||||
{
|
||||
"name": "_devMode"
|
||||
},
|
||||
|
@ -218,6 +230,12 @@
|
|||
{
|
||||
"name": "bindingUpdated"
|
||||
},
|
||||
{
|
||||
"name": "bloomFindPossibleInjector"
|
||||
},
|
||||
{
|
||||
"name": "bloomHashBit"
|
||||
},
|
||||
{
|
||||
"name": "cacheMatchingDirectivesForNode"
|
||||
},
|
||||
|
@ -275,9 +293,6 @@
|
|||
{
|
||||
"name": "currentView"
|
||||
},
|
||||
{
|
||||
"name": "defaultIterableDiffers"
|
||||
},
|
||||
{
|
||||
"name": "defineComponent"
|
||||
},
|
||||
|
@ -302,6 +317,9 @@
|
|||
{
|
||||
"name": "directiveCreate"
|
||||
},
|
||||
{
|
||||
"name": "directiveInject"
|
||||
},
|
||||
{
|
||||
"name": "domRendererFactory3"
|
||||
},
|
||||
|
@ -380,6 +398,9 @@
|
|||
{
|
||||
"name": "getOrCreateElementRef"
|
||||
},
|
||||
{
|
||||
"name": "getOrCreateInjectable"
|
||||
},
|
||||
{
|
||||
"name": "getOrCreateNodeInjector"
|
||||
},
|
||||
|
@ -428,6 +449,9 @@
|
|||
{
|
||||
"name": "initChangeDetectorIfExisting"
|
||||
},
|
||||
{
|
||||
"name": "inject"
|
||||
},
|
||||
{
|
||||
"name": "injectTemplateRef"
|
||||
},
|
||||
|
@ -572,6 +596,12 @@
|
|||
{
|
||||
"name": "scheduleTick"
|
||||
},
|
||||
{
|
||||
"name": "searchMatchesQueuedForCreation"
|
||||
},
|
||||
{
|
||||
"name": "setCurrentInjector"
|
||||
},
|
||||
{
|
||||
"name": "setHostBindings"
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {CommonModule, NgForOf, NgIf} from '@angular/common';
|
||||
import {ChangeDetectionStrategy, Component, EventEmitter, InjectFlags, Injectable, Input, IterableDiffers, NgModule, Output, createInjector, defineInjector, inject, ɵComponentDef as ComponentDef, ɵComponentType as ComponentType, ɵDirectiveDef as DirectiveDef, ɵDirectiveType as DirectiveType, ɵNgOnChangesFeature as NgOnChangesFeature, ɵdefaultIterableDiffers as defaultIterableDiffers, ɵdefineDirective as defineDirective, ɵinjectTemplateRef as injectTemplateRef, ɵinjectViewContainerRef as injectViewContainerRef, ɵmarkDirty as markDirty, ɵrenderComponent as renderComponent} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, Component, EventEmitter, InjectFlags, Injectable, Input, IterableDiffers, NgModule, Output, createInjector, defineInjector, inject, ɵComponentDef as ComponentDef, ɵComponentType as ComponentType, ɵDirectiveDef as DirectiveDef, ɵDirectiveType as DirectiveType, ɵNgOnChangesFeature as NgOnChangesFeature, ɵdefaultIterableDiffers as defaultIterableDiffers, ɵdefineDirective as defineDirective, ɵdirectiveInject as directiveInject, ɵinjectTemplateRef as injectTemplateRef, ɵinjectViewContainerRef as injectViewContainerRef, ɵmarkDirty as markDirty, ɵrenderComponent as renderComponent} from '@angular/core';
|
||||
|
||||
|
||||
export class Todo {
|
||||
|
@ -23,7 +23,7 @@ export class Todo {
|
|||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class TodoStore {
|
||||
todos: Array<Todo> = [
|
||||
new Todo('Demonstrate Components'),
|
||||
|
@ -108,12 +108,9 @@ export class TodoStore {
|
|||
// changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ToDoAppComponent {
|
||||
todoStore: TodoStore;
|
||||
newTodoText = '';
|
||||
|
||||
// TODO(misko) Fix injection
|
||||
// constructor(todoStore: TodoStore) { this.todoStore = todoStore; }
|
||||
constructor() { this.todoStore = new TodoStore(); }
|
||||
constructor(public todoStore: TodoStore) {}
|
||||
|
||||
stopEditing(todo: Todo, editedTitle: string) {
|
||||
todo.title = editedTitle;
|
||||
|
@ -157,10 +154,7 @@ export class ToDoAppComponent {
|
|||
type: NgForOf,
|
||||
selectors: [['', 'ngFor', '', 'ngForOf', '']],
|
||||
factory: () => new NgForOf(
|
||||
injectViewContainerRef(), injectTemplateRef(),
|
||||
// TODO(misko): inject does not work since it needs to be directiveInject
|
||||
// inject(IterableDiffers, defaultIterableDiffers)
|
||||
defaultIterableDiffers),
|
||||
injectViewContainerRef(), injectTemplateRef(), directiveInject(IterableDiffers)),
|
||||
features: [NgOnChangesFeature({
|
||||
ngForOf: 'ngForOf',
|
||||
ngForTrackBy: 'ngForTrackBy',
|
||||
|
|
Loading…
Reference in New Issue