标签: angular4-router

Google Analytics和Angular4 +矩阵网址参数

在我的Angular4 +应用程序中,我使用矩阵表示法来记录url路由参数.Google Analytics(分析)会将网址排除在首次遇到";"之前.我找到了这个,但它没有多大帮助.

有没有办法让GA读取像这样的完整网址,或者我唯一的选择是将它们转换为queryParams?

google-analytics angular angular4-router

15
推荐指数
1
解决办法
292
查看次数

Angular 4隐式流回调和路由器防护

在Angular 4中处理隐式流回调的最佳方法是什么?我希望Guard等待用户重定向回来并使用令牌并在Guard返回true或false之前存储它,我在重定向回检查令牌之前已经获得了拒绝访问路由几秒钟.有没有比我正在做的更好的方式来处理AuthGuard,所以在认证完成之前我没有得到拒绝访问?

如何让路由器保护等待重定向?

AppComponent

    ngOnInit() {    

         //if there is a hash then the user is being redirected from the AuthServer with url params
         if (window.location.hash && !this.authService.isUserLoggedIn()) {     

          //check the url hash
          this.authService.authorizeCallback();

        }
        else if (!this.authService.isUserLoggedIn()) {         

          //try to authorize user if they aren't login
          this.authService.tryAuthorize();       

  }    
}
Run Code Online (Sandbox Code Playgroud)

AuthSerivce

tryAuthorize() {
       //redirect to open id connect /authorize endpoint
        window.location.href = this.authConfigService.getSignInEndpoint();
    }

    authorizeCallback() {       

        let hash = window.location.hash.substr(1);

        let result: any = hash.split('&').reduce(function (result: any, item: string) {
            let …
Run Code Online (Sandbox Code Playgroud)

angular angular4-router

13
推荐指数
1
解决办法
1870
查看次数

Spring Boot/Angular 4 - app中的路由命中服务器

我有一个Angular 4(ES6)应用程序,我想从Spring Boot应用程序提供服务.我的Angular应用程序有一个index.html,当http:// localhost:8080的地址被命中时,Spring Boot知道要映射到在Angular中映射到"/ search"的index.html文件.

但是,我有另一条名为"adminlogin"的路线,我将通过该途径访问

HTTP://本地主机:8080 /后台管理

但在这个例子中,它命中了我的Spring Boot应用程序,它没有映射,然后抛出错误.

如何获取http:// localhost:8080/adminLogin的地址转到我的Angular应用程序?

java routing spring-boot angular angular4-router

13
推荐指数
2
解决办法
7221
查看次数

在角度4延迟加载中将块名称替换为模块名称

我正在使用angular-cli-1.6.3捆绑我的项目.我尝试将延迟加载的块名称重命名为有效的模块名称.但它没有用.代码片段如下,

{path:'lazy',loadChildren:'./ lazy/module#LazyModule?chunkName = LazyModule'}

angular-router-loader angular angular-router angular4-router

11
推荐指数
2
解决办法
5167
查看次数

Angular 4路由器和模态对话框

我有使用Angular路由器的Angular 4 SPA应用程序.我想要使​​用Bootstrap 4在新对话框中打开组件的超链接.我已经知道如何从函数中打开模态对话框.

但是如何使用超链接打开它呢?

<a [routerLink]="['/login']">Login</a>
Run Code Online (Sandbox Code Playgroud)

我想留下我当前的组件,只是在它前面显示模态对话框.

另一个问题 - 是否有可能以编程方式执行此操作?这样我就可以

this.router.navigate(['/login']);
Run Code Online (Sandbox Code Playgroud)

并在当前组件上显示登录模式对话框?

有什么建议?

typescript angular angular4-router

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

如何以角4路线

我有一个角度4项目,当我运行它时localhost:4200/route-a,它工作正常,当我刷新浏览器时,一切都按预期工作.但是,当我使用ng buildapache 构建它并从apache运行它时,导航localhost/route-a返回a 404.这是我的路由代码:

imports: [BrowserModule, HttpModule, FormsModule, RouterModule.forRoot([
    { path: 'home', component: HomeComponent },
    { path: 'route-a', component: RouteAComponent },
    { path: '', redirectTo: '/home', pathMatch: 'full' }
  ])]
Run Code Online (Sandbox Code Playgroud)

apache angular angular4-router

9
推荐指数
2
解决办法
6588
查看次数

Angular 4:路由到路由不起作用

在Angular 4中有一些基本的路由概念,我不明白.

index.html:

<base href="/">
Run Code Online (Sandbox Code Playgroud)

文件结构:

- app
|- app.routings.ts
|- collections
|-- collection.component.ts
|-- collection.component.html
|-- collectioninfo.component.ts
|-- collectioninfo.component.html
|- shared
|-- header.component.html
|-- header.component.ts
Run Code Online (Sandbox Code Playgroud)

我的header.component.html中有一个链接:

<a class="nav-link" [routerLink]="['/collections']">
    Collections
</a>
Run Code Online (Sandbox Code Playgroud)

如果我点击它我登陆localhost:4200 /集合.单击按钮时,将以编程方式更改URL(在collection.component.ts中):

this.router.navigate(['/collections/', collection.name]);
Run Code Online (Sandbox Code Playgroud)

我最终在localhost:4200/collections/name - 一切都很好.现在我以编程方式想要回到/ collections(在collectioninfo.component.ts中):

this.router.navigate(['/collections']);
Run Code Online (Sandbox Code Playgroud)

但这不起作用.该网址没有更改,我收到一条错误消息,指出无法加载参数 - 显然/ collections/name正在再次加载.认为它可能是一个路径问题,但这样的事情也行不通:

this.router.navigate(['../collections']);
Run Code Online (Sandbox Code Playgroud)

附加信息:当我在打开/集合时手动重新加载页面时,我将再次转发到主页,但我认为这是另一个问题,与此行为无关.

app.routing.ts:

const APP_ROUTES: Routes = [
  ...
  { path: 'collections', component: CollectionComponent },
  { path: 'collections/:id', component: CollectionInfo },
];
Run Code Online (Sandbox Code Playgroud)

typescript angular2-routing angular angular4-router

9
推荐指数
2
解决办法
8596
查看次数

使用相同的URL参数重新加载Angular 4+路由

我一直在研究重新加载Angular 4+路由,看起来好像首选的方法是在组件中监听URL参数更改,然后在那里重新初始化组件.

我遇到的问题是尝试找到一个DRY(不要重复自己)的方法来使这个工作跨多个组件,当URL相同(包括参数).在AngularJS中,UI-router很简单.

使用案例:

我有一个可以"浮动"在任何路线上方的通知面板,当点击通知时,它需要转到与之相关的内容 - 这可以是许多不同类型的内容.

例如:/posts/:id/groups/:id/users/:id

如果用户已在查看该内容,则不会重新加载和刷新以反映通知的消息.即"John Doe对您的帖子发表评论"(用户可能正在查看该帖子的过时版本)或"Jane Doe接受您加入Some Group的请求"(用户可能正在查看该组的访客视图).

我确实window.location.reload()在检测到路由是否相同时使用了,并且可行,但由于它导致的开销(角度重新初始化,auth检查,套接字重新连接等),这是非常不受欢迎的.

任何建议将不胜感激!

angular angular4-router

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

routerLink里面的<mat-tab>角度材料

<a routerLink = "/add"></a><mat-tab  label="Add Identity"></mat-tab>
or
<mat-tab  label="Add Identity"> <a routerLink = "/add"></a></mat-tab>.
Run Code Online (Sandbox Code Playgroud)

我是Angular的新手,尝试使用上面Angular材质组件的路由.但是,当我点击"主页"选项卡时,它不会附加网址.对此有任何帮助.

angular angular4-router

9
推荐指数
2
解决办法
2万
查看次数

路由器命名为激活一次的出口

无论在主插座中导航的路线是什么,是否可以将路由器命名为出口一次激活然后永不销毁?

目的是让组件在页面上保持不变(例如,侧边栏),但在初始加载时获得路由的好处 - 例如防护(解析器)和延迟加载.

要求是命名出口不应以任何负面方式影响UX,例如通过向SPA URL引入垃圾后缀,例如(outletName:routeName),它们也不应被意外停用.如果有一种方法可以在初始激活后将它们从路由器中分离出来,那么它是合适的.

skipLocationChange选项不能用于此目的.在此示例中, /login(popup:compose) URL会在按顺序导航ContactLogin路由时显示.

angular2-routing angular angular4-router

9
推荐指数
1
解决办法
511
查看次数