简体   繁体   English

Angular2未正确更新

[英]Angular2 not updated properly

I cloned https://github.com/vladotesanovic/angular2-express-starter in my project for explore angular2 and express. 我在我的项目中克隆了https://github.com/vladotesanovic/angular2-express-starter ,用于探索angular2和express。

What I want to is just "Hello World" level, so it looks complicated I deleted every files in modules folder. 我想要的只是“Hello World”级别,所以看起来很复杂我删除了modules文件夹中的每个文件。

and I deleted injecting modules in app.modules.ts file. 我在app.modules.ts文件中删除了注入模块。

so my app.modules.ts is below : 所以我的app.modules.ts如下:

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { provideAuth } from "angular2-jwt";
import { HttpModule } from "@angular/http";
import { NgSemanticModule } from "ng-semantic";

import { AppComponent }  from './app.component';

@NgModule({
    imports: [
        BrowserModule,
        HttpModule,
        NgSemanticModule,
    ],
    providers: [
        provideAuth({
            globalHeaders: [{"Content-type": "application/json"}],
            newJwtError: true,
            noTokenScheme: true
        })
    ],
    declarations: [  AppComponent ],
    bootstrap:    [ AppComponent ],
    schemas: [
        CUSTOM_ELEMENTS_SCHEMA
    ]
})
export class AppModule {}

as you can see, there is no other module in imports and declarations. 如您所见,导入和声明中没有其他模块。

and I edit app.component.ts, the root component. 我编辑了根组件app.component.ts。 like below: 如下:

import { Component, ViewChild } from "@angular/core";
import "rxjs/add/operator/map";

@Component({
    selector: "app",
    template: `<h1> Hello Angular 2 </h1>`
})

export class AppComponent {

}

What I expected just showing "Hello Angular 2". 我期望只显示“Hello Angular 2”。

but the browser still request deleted page. 但浏览器仍然请求删除页面。 the component was deleted. 该组件已删除。 Where and why angular2 request that file? angular2为什么和为什么请求该文件?

Is my way wrong? 我错了吗? I am having problem since yesterday, It looks very difficult to setting. 我从昨天开始遇到问题,设置起来很困难。

在此输入图像描述

try removing providers from app.module.ts : 尝试从app.module.ts 删除 providers

    providers: [
            provideAuth({
                globalHeaders: [{"Content-type": "application/json"}],
                newJwtError: true,
                noTokenScheme: true
            })
        ]  

our authService is implemented in home.component.ts ( https://github.com/vladotesanovic/angular2-express-starter/blob/master/client/modules/home/home.component.ts ) and it's being called. 我们的authService在home.component.tshttps://github.com/vladotesanovic/angular2-express-starter/blob/master/client/modules/home/home.component.ts )中实现,并且正在调用它。

What does index.html look like? index.html是什么样的? It must contain the "app" tag 它必须包含“app”标记

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

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