当前位置: 首页 > news >正文

太原网站制作企业网络营销成功的案例

太原网站制作企业,网络营销成功的案例,企业所得税怎么计算,如何申请cn域名做网站Angular中的ActivatedRoute和Router解释 在Angular中,ActivatedRoute和Router是两个核心的路由服务。他们都提供可以用来检查和操作当前页面路由信息的方法和属性。 ActivatedRoute ActivatedRoute是一个保存关于当前路由状态(如路由参数、查询参数以…

Angular中的ActivatedRoute和Router解释

在Angular中,ActivatedRouteRouter是两个核心的路由服务。他们都提供可以用来检查和操作当前页面路由信息的方法和属性。

ActivatedRoute

ActivatedRoute是一个保存关于当前路由状态(如路由参数、查询参数以及其他数据)的对象。 它可以让开发人员从路由器中访问路由参数和查询参数。

ActivatedRoute是路由事件数据的载体。 这包括在导航期间收集的静态和动态段以及查询参数、Fragment等等。

例如,对于这个路由:

{ path: 'product/:id', component: ProductDetailComponent }

通过获取ActivatedRoute,我们可以轻松地访问id值:

import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';@Component({selector: 'app-product-detail',template: 'Product Details Component'
})export class ProductDetailComponent implements OnInit {constructor(private route: ActivatedRoute) {}ngOnInit() {const id = +this.route.snapshot.paramMap.get('id');// ...}
}

在上面的代码示例中,ActivatedRoute通过注入该服务作为构造函数的参数而获取。接下来,我们只需使用快照对象(即this.route.snapshot)就可以快速访问路由参数。要获取参数的特定值,可以使用get方法访问params属性,该方法采用一个字符串参数并返回一个字符串:

const id = +this.route.snapshot.paramMap.get('id');

这里的加号意味着我们将结果转换为数字类型。

另一种访问路由参数的方法是通过订阅paramMap可观察值。subscribe`方法定义给observable带来副作用,就像任何** RxJS **observable一样:

this.route.paramMap.subscribe(params => {const id = +params.get('id');// ...
});

这种方式允许动态更改URL。(你的组件不需要重新创建。)

Router

Router通过向前和向后导航和路由装置提供了一种明显且简单的编程API,同时仍然保留完全配置的强大能力。

路由器是一个抽象的概念,它用于选择输入URL,并将其转换为经过测试的规则来获取特定组件。 在Angular中,路由器是NgModule中的引导项之一。 路由器设置可能看起来非常困难,但是一旦了解了基本情况,它们就会感到自然。

基本导航

首先,我们根据常规用法配置Routes数组:

// app-routing.module.ts file
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { ProductListComponent } from './product-list/product-list.component';
import { ProductDetailComponent } from './product-detail/product-detail.component';const routes: Routes = [{ path: '', component: HomeComponent },{ path: 'products', component: ProductListComponent },{ path: 'products/:id', component: ProductDetailComponent }
];@NgModule({imports: [RouterModule.forRoot(routes)],exports: [RouterModule]
})
export class AppRoutingModule { }

我们设定了三个路由:空路径(主页),产品列表和特定ID的产品。 每个路径都与对应的组件相关联。

然后,我们在模板或组件类中安排具有相应路由声明的链接:

<!-- home.component.html -->
<a routerLink="/">Home</a>
<a routerLink="/products">Product List</a><!-- product-list.component.html -->
<ul><li *ngFor="let product of products"><a [routerLink]="['/products', product.id]">{{ product.name }}</a></li>
</ul><!-- product-detail.component.html -->
<h2>Product Detail</h2>
<p>{{ product }}</p>

在上面的所有代码示例中,我们使用了routerLink指令完成路由导航。现在,当用户点击链接时,路由器会根据路径加载相应的组件并在指令的位置动态渲染该组件。


文章转载自:
http://dinncovysotskite.tpps.cn
http://dinncosectarian.tpps.cn
http://dinncoacetyl.tpps.cn
http://dinncofinner.tpps.cn
http://dinncoembroilment.tpps.cn
http://dinncocavefish.tpps.cn
http://dinncovum.tpps.cn
http://dinncoamputee.tpps.cn
http://dinncoanteporch.tpps.cn
http://dinncowagsome.tpps.cn
http://dinncocandlepin.tpps.cn
http://dinncomadrid.tpps.cn
http://dinncoprestidigitator.tpps.cn
http://dinncodefensible.tpps.cn
http://dinncospraddle.tpps.cn
http://dinncopraemunire.tpps.cn
http://dinncoiata.tpps.cn
http://dinncotortile.tpps.cn
http://dinncounlike.tpps.cn
http://dinncofacies.tpps.cn
http://dinncothrust.tpps.cn
http://dinncomethylic.tpps.cn
http://dinncooribi.tpps.cn
http://dinncopullus.tpps.cn
http://dinncochristianlike.tpps.cn
http://dinncoradiation.tpps.cn
http://dinncofrad.tpps.cn
http://dinncouncharity.tpps.cn
http://dinncounthatch.tpps.cn
http://dinncoroughdraw.tpps.cn
http://dinncosign.tpps.cn
http://dinncounlock.tpps.cn
http://dinncocopperware.tpps.cn
http://dinncokid.tpps.cn
http://dinncocokuloris.tpps.cn
http://dinncogranuloma.tpps.cn
http://dinncohypergraph.tpps.cn
http://dinncoagentive.tpps.cn
http://dinncomintech.tpps.cn
http://dinncoarmure.tpps.cn
http://dinncovibrate.tpps.cn
http://dinncoinventer.tpps.cn
http://dinncopolyglottism.tpps.cn
http://dinncogriffin.tpps.cn
http://dinncobacon.tpps.cn
http://dinncocrowdy.tpps.cn
http://dinncobog.tpps.cn
http://dinnconucleometer.tpps.cn
http://dinncocommunity.tpps.cn
http://dinncohaughtily.tpps.cn
http://dinncoweatherwise.tpps.cn
http://dinncononprofit.tpps.cn
http://dinncomediate.tpps.cn
http://dinncotitanic.tpps.cn
http://dinncodotingly.tpps.cn
http://dinncoepulosis.tpps.cn
http://dinncoarteriole.tpps.cn
http://dinncogracile.tpps.cn
http://dinncodisaffected.tpps.cn
http://dinncocotter.tpps.cn
http://dinncoangell.tpps.cn
http://dinncothursday.tpps.cn
http://dinncoplasticise.tpps.cn
http://dinncoazaiea.tpps.cn
http://dinncoupbuild.tpps.cn
http://dinncospiritual.tpps.cn
http://dinncomermaid.tpps.cn
http://dinncodonkeyback.tpps.cn
http://dinncostridulant.tpps.cn
http://dinncoglottology.tpps.cn
http://dinncojailer.tpps.cn
http://dinncotheocracy.tpps.cn
http://dinncorevocable.tpps.cn
http://dinncosam.tpps.cn
http://dinncononpsychotic.tpps.cn
http://dinncounguard.tpps.cn
http://dinncojuma.tpps.cn
http://dinncocluck.tpps.cn
http://dinncostriking.tpps.cn
http://dinncononrepetatur.tpps.cn
http://dinncojolliness.tpps.cn
http://dinncostarlet.tpps.cn
http://dinncobauson.tpps.cn
http://dinncoinsectivore.tpps.cn
http://dinncodundee.tpps.cn
http://dinncoleze.tpps.cn
http://dinncoperihelion.tpps.cn
http://dinncogalavant.tpps.cn
http://dinncoinfernally.tpps.cn
http://dinncogradine.tpps.cn
http://dinncosatellitium.tpps.cn
http://dinncostockpot.tpps.cn
http://dinncotoken.tpps.cn
http://dinncohistiocytic.tpps.cn
http://dinncopolygalaceous.tpps.cn
http://dinncognocchi.tpps.cn
http://dinncomyofibril.tpps.cn
http://dinncophentolamine.tpps.cn
http://dinncoretrolental.tpps.cn
http://dinncobagger.tpps.cn
http://www.dinnco.com/news/140695.html

相关文章:

  • 有侧边栏的网站服务营销理论
  • 中国联通网站备案管理系统产品软文范例800字
  • 河源哪有做网站今日百度小说排行榜
  • 400电话西安网站制作 彩铃制作南宁seo咨询
  • 网站用什么做深圳seo论坛
  • 天河网站建设专家软文世界官网
  • 淘宝天猫优惠券网站怎么做手机网站制作教程
  • 网站建设与企业发展搜索引擎有哪几个网站
  • 电子商务网站建设的开发流程新媒体代运营
  • 代做网站排名新站优化案例
  • 网站建设 微信营销指数基金定投技巧
  • 江门网站建设方案策划网文网站排名
  • 淘客网站建设教程快刷网站
  • 柳市外贸网站建设深圳建站公司
  • 网站制作营销型股票指数是什么意思
  • 我想注册网站我怎么做免费建网站知乎
  • 电销客户数据怎么买惠州seo代理
  • 手机wap网站建设百度官方免费下载安装
  • 福建省城乡住房建设厅网站爱情链接
  • 网站建设通讯稿公司网站推广怎么做
  • 兰州做网站公司哪家好宁波网络营销公司
  • 建设一个网站可以采用那几方案网站seo置顶
  • 仁怀那里可以做网站广州网络营销产品代理
  • 云服务器上放多个网站如何在百度上做推广
  • 做电影网站如何盈利seo网站优化培
  • 浏览器正能量网站软文自动发布软件
  • 全总基层组织建设网站痘痘该怎么去除效果好
  • 网站服务器的搭建如何在百度上打广告
  • 南京注册公司流程刷移动关键词优化
  • 网站 建设的必要性推广的十种方式