How to create a reusable component in Angular 2 Without Typescript

In the examples I found for Angular 2, components can be created once for each application as such:

(function(app) { 
  app.AppComponent =
    ng.core.Component({
      selector: 'my-app',
      template: '<h1>My First Angular 2 App</h1>'
    })
    .Class({
      constructor: function() {}
    });
})(window.app || (window.app = {}));

with loading the app / main.js component:

(function(app) {
  document.addEventListener('DOMContentLoaded', function() {
    ng.platform.browser.bootstrap(app.AppComponent);
  });
})(window.app || (window.app = {}));

But how can I identify a reusable component? The documentation is submitted in Typescript format or for Angular 1.

+4
source share
1 answer

. directive , <my-app></my-app> ( , , - , <my-user-details [user]="user"></my-user-details>). Angular 2 .

, , smart ( ) dumb ( ), .

0

Source: https://habr.com/ru/post/1628071/


All Articles