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