小编Der*_*own的帖子

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
查看次数

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
查看次数

ReactDOM.render与React Component呈现差异

我已经开始学习React了.render()方法用于两个地方:

  1. 使用ReactDOM.render()
ReactDOM.render( <
  Test / > ,
  document.getElementById('react-application')
);
Run Code Online (Sandbox Code Playgroud)
  1. 其他是扩展组件的内部类.
class Test extends React.Component {
  render() {
    return ( <
      div > Hello < /div>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

这两种渲染方法之间的确切区别是什么?

html javascript reactjs

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

Google Calendar API ACL规则未向非Google电子邮件地址发送邀请

我们正在寻找有关通过Google Calendar v3 API共享Google日历帐户访问权限的一些特定专业知识.创建日历后,我们将创建ACL规则以允许其他电子邮件地址访问.我们的问题在于将自动生成的邀请发送到非Google电子邮件地址.与自动将日历添加到Gmail地址日历的Gmail地址不同,我们发现,如果以前未将电子邮件地址与Google帐户关联,则该地址不会自动从Google收到Google的邀请.如果地址是通过Web浏览器界面手动共享的话.我们可以通过从日历的共享列表中手动删除API创建的ACL规则手动删除邀请,然后再次手动添加电子邮件地址,提示发送邀请.当然,我们希望在API添加ACL规则时自动发送邀请.

请注意,这与发送事件通知无关.这是用于访问以查看日历本身.

是否有任何具有相关经验的人可以启发我们这种行为?

php google-calendar-api google-api google-api-php-client

8
推荐指数
0
解决办法
363
查看次数

Angular 4路由器:阻止直接浏览器导航

如何说服Angular 4路由器在我的应用程序中禁用直接浏览器导航?

我已经查看了路由器钩子CanActivateCanDeactivate实现了它们,但CanDeactivate在使用直接浏览器导航时根本不会触发.

我可以CanActivate用来阻止网址,但只有在应用程序重新启动后,这需要时间和浏览器窗口中的不需要的更改.

我希望能够在应用重新启动之前捕获直接浏览器导航.

如果这有帮助:我想完全禁止直接浏览器导航,所以我不需要允许某些网址并禁用其他网址的解决方案.

这是我的路由器定义:

const routes: Routes = [
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
  { path: 'dashboard', component: DashboardComponent, canActivate: [RouteGuardService] },
  { path: 'users', component: UsersMainComponent, canActivate: [RouteGuardService] },
  { path: 'vendors', component: VendorMainComponent, canActivate: [RouteGuardService] },
  { path: 'invoices', component: InvoicesMainComponent, canActivate: [RouteGuardService] },
  { path: 'offers' , component: EsdMainComponent, canActivate: [RouteGuardService] },
  { path: 'settings' , component: SettingsMainComponent, canActivate: [RouteGuardService] },
  // Callback …
Run Code Online (Sandbox Code Playgroud)

angular-routing angular angular4-router

7
推荐指数
2
解决办法
6795
查看次数

是否有ByteString的追加运算符?

对于String ++,有类型

> :t (++)
(++) :: [a] -> [a] -> [a]
Run Code Online (Sandbox Code Playgroud)

显然它不起作用,ByteString因为它不是一个列表.我看到了这个append功能,但它有一个操作员吗?

haskell concatenation bytestring

7
推荐指数
1
解决办法
357
查看次数

将现有Docker映像部署到Heroku

我无法将现有的docker映像部署到Heroku。

图片

docker run -it --name xp-home enonic/xp-home
docker run -d -p 8080:8080 --volumes-from xp-home --name xp-app enonic/xp-app
Run Code Online (Sandbox Code Playgroud)

我采取的步骤。

heroku login
sudo heroku container:login
sudo docker tag dpd-image registry.heroku.com/hidden-mountain-63983/web
sudo docker push registry.heroku.com/hidden-mountain-63983/web
heroku open -a hidden-mountain-63983
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么?

先感谢您

heroku

6
推荐指数
1
解决办法
532
查看次数