小编Lis*_*kor的帖子

使用角度为2的按钮导航到另一个页面

我试图通过单击按钮导航到另一个页面,但它无法正常工作.可能是什么问题呢.我现在正在学习角度2,现在对我来说有点难度.

//Routes/Path in a folder call AdminBoard

export const AdminRoutes: Routes =[

  {
    path: 'dashboard',

    component: AdminComponent,
    children: [
      {path: '', redirectTo: 'Home'},
      {path: 'Home', component: HomeComponent},
      {path: 'Service', component: ServiceComponent},
      {path: 'Service/Sign_in', component:CustomerComponent}

    ]

  }

];

//Button is also in a different folder. Click button to navigate to this page           {path: 'Service/Sign_in', component:CustomerComponent}

  <button class="btn btn-success pull-right" ><a routerLink="/Service/Sign_in"> Add Customer</a></button>
Run Code Online (Sandbox Code Playgroud)

angular

91
推荐指数
4
解决办法
26万
查看次数

如何延迟角度2

我试图在我的应用程序中设置显示延迟.运行程序后,消息显示正确,而不是仅显示4秒钟.这是我的延迟功能.可能有什么不对

 display(){    
      this.foodservice.getFood()
          .subscribe(data => 
          {
             delay (4000)
             this.display =""
          });
   }
Run Code Online (Sandbox Code Playgroud)

angular

20
推荐指数
1
解决办法
4万
查看次数

找不到'@ angular/compiler'模块

我运行命令npm install -g @ angular/cli,在我试图运行我的应用程序后,它说,在终端中找不到模块'@ angular/compiler'.如何在我的package.json中安装编译器以编译我的应用程序

//package
{
  "name": "Restaurant",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.4.9",
    "@angular/compiler": "~2.4.9",
    "@angular/core": "~2.4.9",
    "@angular/forms": "~2.4.9",
    "@angular/http": "~2.4.9",
    "@angular/platform-browser": "~2.4.9",
    "@angular/platform-browser-dynamic": "~2.4.9",
    "@angular/router": "~3.4.9",
    "@types/lodash": "^4.14.50",
    "angular-2-data-table": "^0.1.2",
    "angular2-datatable": "^0.5.2",
    "core-js": "^2.4.1",
    "lodash": "^4.17.4",
    "ng2-date-picker": "^0.2.1",
    "ng2-file-upload": "^1.1.2",
    "ng2-modal": "0.0.25",
    "ng2-pagination": "^2.0.1",
    "ng2-table": "^1.3.2",
    "primeng": "^2.0.1",
    "rxjs": "5.2.0",
    "tinymce": "^4.5.2",
    "ts-helpers": …
Run Code Online (Sandbox Code Playgroud)

angular

16
推荐指数
5
解决办法
5万
查看次数

使用checbox删除多行

我可以通过选中一个框来删除单行.当我尝试选择多个框时,当前复选框是唯一删除的行,而前面选中的复选框.以下是我的代码.请帮忙

//Service

import {Injectable} from '@angular/core';
import {Observable} from "RxJS/Rx";
import {Http, Response, Headers} from '@angular/http';

@Injectable()

export class FoodService {    

    constructor(private http:Http) {

    }

    RemoveFood(id) {
        return this.http.delete('http://example.com ' + id)
        .map((response:Response) => response.json())
    }
}
Run Code Online (Sandbox Code Playgroud)

//食物模块

export class Food (
    public count: number;
    public price: number;
    public location: string;
    public type: string;
    public selected: string;    
) { }
Run Code Online (Sandbox Code Playgroud)

//食物桌

<tr *ngFor="let food of Food">

    <td><input #{{food.count}} [(ngModel)]="food.selected" type="checkbox" (change)="checkbox(food)"></td>
    <td>{{food.count}}</td>
    <td>{{food.price}}</td>
    <td>{{food.location}}</td>
    <td>{{food.type}}</td>

</tr>
Run Code Online (Sandbox Code Playgroud)

//食物成分

export class FoodComponent …
Run Code Online (Sandbox Code Playgroud)

angular

2
推荐指数
1
解决办法
2802
查看次数

标签 统计

angular ×4