Unexpected value for directive 'undefined' in component view (angular 2.0)

I am using angular 2.0 latest alpha, then I am using es5 as the code for it. when i add directives to view annotation i run into error.

plunkr: http://plnkr.co/edit/eJqmvaiDyypPOexr0IgF

place.annotations = [
    new angular.ComponentAnnotation({
        selector: 'ph-place',
        injectables: [Service.Places]
    }),
    new angular.ViewAnnotation({
        template: '<ul><li *for="#place of places">{{ place }}</li></ul>',
        directives: [angular.For]
    })
];

      

+3


source to share


2 answers


Comment by github angular 2.0 release gdi2290

@VirtualOverride the problem was that the docs in angular.io were still out of date. Here's your example working with alpha .25 plnkr.co/edit/ks0Sbv?p=preview, modified it a bit and made some helper annotations in Utils. I've also added the original as old if you'd rather "

I needed to make a couple of changes:

The main problem, Changed Injection for appInjector in directive settings, which were changed with new alpha version.



new angular.ComponentAnnotation({
        selector: 'ph-place',
        appInjector: [Service.Places]
    }),

      

Changed for NgFor:

 new angular.ViewAnnotation({
        template: '<ul><li *ng-for="#place of places">{{ place }}</li></ul>',
        directives: [angular.NgFor]
    })

      

Demo

+2


source


Now the "For" directive has now changed to NgFor:



place.annotations = [
    new angular.ComponentAnnotation({
        selector: 'ph-place',
        injectables: [Service.Places]
    }),
    new angular.ViewAnnotation({
        template: '<ul><li *ng-for="#place of places">{{ place }}</li></ul>',
        directives: [angular.NgFor]
    })
];

      

0


source







All Articles