最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Angular7.2.7路由使用初體驗(yàn)

 更新時(shí)間:2019年03月01日 11:12:24   作者:默默無聞  
這篇文章主要介紹了Angular7.2.7路由使用初體驗(yàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

本文記錄自己在學(xué)習(xí)angular中對(duì)路由的理解

angular路由不在angular的包中, 如果要使用angular的路由, 需要從@angular/router中引入

路由的使用:

子路由使用:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const route: Routes = [
{path: 'browse-product', component: BrowseProductComponent},
{path: 'buy-product', component: BuyProductComponent}
]

@NgModule({
imports: [RouterModule.ferChild(route)], // 子路由使用ferChild方法
exports: [RouterModule]
})

export class ChildRoutingModule {}

父組件中:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const route: Route = [
{
  path: '',
  children: [
   {path: '', redirectTo: '/user/browse-product', pathMatch: 'full'},
   {path: 'user', loadChildren: './user/user.module#UserModule'},
   {path: 'admin', loadChildren: './admin/admin.module#AdminModule'},
  ]
 }
]

@NgModule({
imports: [RouterModule.forRoot(root, {useHash: false})],
exports: [RouterModule]
})

export class ParentRoutingModule {}

在app.module.ts中導(dǎo)入模塊

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ParentRoutingModule } from 'parentRoutingModule';
@NgModule({
declarations: [
  AppComponent,
 ],
 imports: [
  BrowserModule,
  RouterModule,
  ParentRoutingModule
 ]
})

然后在app.component.html中加入router-outlet即可, router-outlet就是路由的出口, 表示路由對(duì)應(yīng)的組件應(yīng)該在這里顯示.

<h1>Angular Router</h1>
<nav>
 <a routerLink="/user/browse-product">browse-product</a> &nbsp;
 <a routerLink="/user/buy-product">buy-product</a>&nbsp;
 <a routerLink="/admin/manage-product">manage-product</a>&nbsp;
 <a routerLink="/admin/operator-record">operator-record</a>&nbsp;
</nav>
<router-outlet></router-outlet>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 詳解Angularjs 自定義指令中的數(shù)據(jù)綁定

    詳解Angularjs 自定義指令中的數(shù)據(jù)綁定

    這篇文章主要介紹了Angularjs 自定義指令中的數(shù)據(jù)綁定,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • AngularJS 自定義過濾器詳解及實(shí)例代碼

    AngularJS 自定義過濾器詳解及實(shí)例代碼

    這篇文章主要介紹了AngularJS 自定義過濾器,這里整理了相關(guān)資料及示例代碼,有興趣的小伙伴可以參考下
    2016-09-09
  • 詳解Angular組件數(shù)據(jù)不能實(shí)時(shí)更新到視圖上的問題

    詳解Angular組件數(shù)據(jù)不能實(shí)時(shí)更新到視圖上的問題

    這篇文章主要為大家介紹了Angular組件數(shù)據(jù)不能實(shí)時(shí)更新到視圖上的問題詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • angular ng-repeat數(shù)組中的數(shù)組實(shí)例

    angular ng-repeat數(shù)組中的數(shù)組實(shí)例

    下面小編就為大家?guī)硪黄猘ngular ng-repeat數(shù)組中的數(shù)組實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-02-02
  • 在Angular中實(shí)現(xiàn)懶加載的示例代碼

    在Angular中實(shí)現(xiàn)懶加載的示例代碼

    在Angular中,懶加載技術(shù)通過路由配置實(shí)現(xiàn)模塊的按需加載,可優(yōu)化應(yīng)用啟動(dòng)時(shí)間和減少初始加載代碼量,首先創(chuàng)建獨(dú)立模塊,在模板中使用<router-outlet>插入懶加載組件,并可采用預(yù)加載策略如PreloadAllModules,以提前加載所有懶加載模塊,優(yōu)化加載性能
    2024-10-10
  • AngularJS實(shí)現(xiàn)根據(jù)變量改變動(dòng)態(tài)加載模板的方法

    AngularJS實(shí)現(xiàn)根據(jù)變量改變動(dòng)態(tài)加載模板的方法

    這篇文章主要介紹了AngularJS實(shí)現(xiàn)根據(jù)變量改變動(dòng)態(tài)加載模板的方法,結(jié)合實(shí)例形式簡(jiǎn)單分析了AngularJS動(dòng)態(tài)加載模板的主要操作技巧與模板實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2016-11-11
  • angular 實(shí)時(shí)監(jiān)聽input框value值的變化觸發(fā)函數(shù)方法

    angular 實(shí)時(shí)監(jiān)聽input框value值的變化觸發(fā)函數(shù)方法

    今天小編就為大家分享一篇angular 實(shí)時(shí)監(jiān)聽input框value值的變化觸發(fā)函數(shù)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-08-08
  • 如何以Angular的姿勢(shì)打開Font-Awesome詳解

    如何以Angular的姿勢(shì)打開Font-Awesome詳解

    這篇文章主要給大家介紹了關(guān)于如何以Angular的姿勢(shì)打開Font-Awesome的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Angular具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-04-04
  • 詳解如何在Angular優(yōu)雅編寫HTTP請(qǐng)求

    詳解如何在Angular優(yōu)雅編寫HTTP請(qǐng)求

    這篇文章主要介紹了詳解如何在Angular優(yōu)雅編寫HTTP請(qǐng)求,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-12-12
  • angularjs實(shí)現(xiàn)table增加tr的方法

    angularjs實(shí)現(xiàn)table增加tr的方法

    下面小編就為大家分享一篇angularjs實(shí)現(xiàn)table增加tr的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02

最新評(píng)論

出国| 台中县| 安泽县| 松溪县| 商河县| 舞钢市| 定结县| 马公市| 彩票| 长宁县| 阳新县| 武鸣县| 旬邑县| 抚松县| 宁远县| 庆阳市| 靖边县| 姜堰市| 杂多县| 改则县| 安新县| 武邑县| 乌鲁木齐县| 陕西省| 安阳县| 日喀则市| 阳城县| 铜川市| 叙永县| 奉新县| 大化| 双桥区| 崇左市| 抚州市| 伽师县| 绥棱县| 类乌齐县| 临安市| 中方县| 榆林市| 清丰县|