运行服务时不生成组件生成组件

时间:2017-08-07 04:31:46

标签: angularjs

iam添加新的ng generate组件用户项

此代码user-item.component.ts
我们开始在项目中使用AngularJS但是当运行服务时不显示结果页面.whats问题

import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
  selector: 'app-user-item',
  templateUrl: 'user-item.component.html',
  styleUrls: ['user-item.component.css']
})

export class UserItemComponent implements OnInit {
    name: string;
    constructor() {
    this.name = 'test';
    }

    ngOnInit() {

  }

}

用户item.component.html

   <p>
      user-item works!
    </p>

此代码app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { UserItemComponent } from './user-item/user-item.component';
import { UserListComponent } from './user-list/user-list.component';

@NgModule({
  declarations: [
    AppComponent,
    UserItemComponent,
    UserListComponent,


  ],
  imports: [
      BrowserModule,
      FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent, UserItemComponent]
})
export class AppModule { }

的index.html

<body>
    <app-user-item></app-user-item>
    --
    <app-user-list></app-user-list>
    --
  <!--<app-root></app-root>-->
    -----

</body>

0 个答案:

没有答案