简体   繁体   English

Angular2-Meteor:如何在应用外重用组件

[英]Angular2-Meteor: how to re-use components outside my app

I have been following a tutorial to create a demo app using Angular2-Meteor. 我一直在遵循使用Angular2-Meteor创建演示应用程序的教程。

Link to tutorial: http://www.angular-meteor.com/tutorials/socially/ 链接到教程: http : //www.angular-meteor.com/tutorials/socially/

I have an external web page where I would like to use some components from the app. 我有一个外部网页,我想在其中使用该应用程序中的某些组件。

This is the PartiesList component declaration, from the tutorial: 这是来自教程的PartnersList组件声明:

import 'reflect-metadata';
import {Component} from 'angular2/core';
import {Parties} from '../../../collections/parties.ts';
import {PartiesForm} from '../parties-form/parties-form.ts';

@Component({
  selector: 'parties-list',
  templateUrl: '/client/imports/parties-list/parties-list.html',
  directives: [PartiesForm]
})

export class PartiesList {
  parties: Mongo.Cursor;

  constructor() {
    this.parties = Parties.find();
  }

  removeParty(party) {
    Parties.remove(party._id);
  }
}

Is it possible to use this component outside the app, in another html file, for example: 是否可以在应用程序外部的另一个html文件中使用此组件,例如:

<body>
...
<parties-list></parties-list>
</body>

Thanks in advance. 提前致谢。

You can use it in an Angular application like 您可以在Angular应用程序中使用它,例如

bootstrap(PartiesList)

or in the view of another Angular component. 或从另一个Angular组件的角度来看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM