[UPDATE] Please read the comment history to understand the context.
Everything:
I'm new to angular2, when I follow the quick start guide, one question confuses me:
I simplify app.component.ts as:
import { Component } from "angular2/core"; @Component({ selector: "my-app", template: "<div>{{title}}</div>" }) export class AppComponent { title = "Tour of Heroes" + Math.random(); }
And add another my-app tag to index.html, for example:
<body> <my-app>Loading...</my-app> <my-app>Loading...</my-app> </body>
I wonder why the second can not be displayed?
Another question related to this:
If I put two instances of the same component, each of them will save its own member variable, but if I add the service to one component, then all instances of the components will have the same service instance, I believe that the only obvious diff - they use different annotations (in addition, they both export the class): @Component and @Injectable, and one in the array of directives, and the other in the array of providers. I wonder if these 2 angular annotations tell how to handle an instance or array of directives and an array of providers?
source share