displays the Herolistcomponent component in
5.[routerlink]
We added the Routerlink directive to the
If Routerlink wants to bind dynamic information, we can bind it to a template expression that can return an array of routing links. The router will eventually parse the array into a URL and a component view.
We can also add a routerlinkactive directive to
= "Search"(Keyup.enter)= "Getherobyindex (inpref.value)"#inpRef>ul> Li*ngfor= "Let Hero of Heros | async"> a[Routerlink]= "Hero.id"routerlinkactive= "Active"[Routerlinkactiveoptions]= "{exact:true}">{{Hero.name}}a> Li> we can also do [routerlink]= "['/heros ', hero.id]", this would point to "HEROS/1"; If you do: [routerlink]= "[' heros ', hero.id]", this wo
Import {routing} from './app.routing ';
@NgModule ({
imports: [
browsermodule,
routing
],
declarations: [
appcomponent
//Some Component
],
bootstrap: [Appcomponent]
})
export class Appmodule {}
In this way, we refer to our configured routers in the @ngmodule imports.
4. Using Routing in Templates
By completing the 2 and 3 steps above, we can use routing in the template
App.component.ts
Template: '
We added the
components.module.ts, add 2 sentences: from ' ./myinfo.component ' ;d eclarations: [... Myinfocomponent]Page added, you have to configure the menu to click in, open the layouts directory under the full-layout.component.html, add under Componentsclass="nav-item"class="nav-link " Routerlinkactive="active" [routerlink]="['/components/myinfo '] "class="icon-star">Why would you like to open the full-layout.component.html file plus menu? And above is the
navigating to this route.
If you want the URL to be localhost:4200/cesium3d , navigate to Cesium3dcomponent.You first import the cesium3dcomponent so that you can Route reference it in. Then define a route array where one of the routes is pointing to the component.Import {Ngmodule} from ' @angular/core '@angular/common '@angular/router './cesium3d/ Cesium3d.component ';Const Routes:routes = [{path: ' Cesium3d ', component:cesium3dcomponent}]; @NgModule ({imports: [Commonmodule],Exports: [R
the recipient's routing address/detail---"/detail/:indexthis.$ Route.params.index2. Send Routerlink to= "/DETAIL/20" this. $router. Push ('/detail/20 ')5. Routing Nestingin a route, path corresponds to a component, and if the component needs to load other component according to different URLs, it is called a nested example of a route: for example a component now needs to be based on a different URL, Load B components or C components 1. Specify a con
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.