小编Rob*_*ert的帖子

Angular2路由/深层链接不能与Apache 404一起使用

我正在关注Angular 2路由示例.使用"精简"网络服务器我可以从根和深层链接工作导航,但是使用Apache我可以从根导航,但是当跟随链接指向路由时会得到404 Not Found错误.

例如,以下URL对npm由端口3000启动的"lite"Web服务器起作用.

http://localhost:3000/crisis-center/2
Run Code Online (Sandbox Code Playgroud)

但是在端口80上运行Apache的下一个URL失败了.

http://localhost/crisis-center/2
The requested URL /crisis-center/2 was not found on this server.
Run Code Online (Sandbox Code Playgroud)

我确实尝试了一些针对类似Angular 1问题推荐的.htaccess解决方案,但没有运气.如果有人在Apache上有Angular 2路由和深层链接工作,请告诉我你是如何实现的.

@RouteConfig([
{ // Crisis Center child route
path: '/crisis-center/...',
name: 'CrisisCenter',
component: CrisisCenterComponent,
useAsDefault: true
},

{path: '/heroes',   name: 'Heroes',     component: HeroListComponent},
{path: '/hero/:id', name: 'HeroDetail', component: HeroDetailComponent},
{path: '/disaster', name: 'Asteroid', redirectTo: ['CrisisCenter',  'CrisisDetail', {id:3}]}
])
Run Code Online (Sandbox Code Playgroud)

Boot.ts

import {bootstrap}        from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {AppComponent}     from './app.component';
bootstrap(AppComponent, [ROUTER_PROVIDERS]);
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular

27
推荐指数
4
解决办法
3万
查看次数

如何让Mathjax与Angular2一起使用?

有没有人让Mathjax与Angular2合作?

Plunkr示例创建: - http://plnkr.co/edit/FLduwmtHfkCN5XPfzMsA?p=preview

从一些Angular1示例中我看到它看起来像需要一个指令来调用MathJax.Hub.Queue,但我怀疑我需要花费很长时间来使Angular 2语法正确,所以我想知道是否有人已经完成了它?

例如,以下是Angular 1示例. https://github.com/ColCarroll/ngMathJax/blob/master/ng-mathjax.js

mathjax语法在这里: - https://docs.mathjax.org/en/v1.1-latest/typeset.html

尝试在Angular2中做类似的事情.

更新 - 感谢Thierry,以下工作.

零件:-

import {Component, OnInit} from 'angular2/core';
import {MathJaxDirective} from './mathjax.directive';

@Component({
  selector: 'hello-mathjax',
  templateUrl: 'app/hello_mathjax.html',
  directives: [MathJaxDirective]
})
export class HelloMathjax {
  fractionString: string = 'Inside Angular one half = $\\frac 12$';
  index: number = 3;

    ngOnInit() {
        MathJax.Hub.Queue(["Typeset",MathJax.Hub,"MathJax"]);
    }

    update () {
      this.fractionString = 'Inside Angular one third = $\\frac 1'+this.index+'$';
      this.index++;
    }

}
Run Code Online (Sandbox Code Playgroud)

指示:-

import {Directive, ElementRef, Input} from 'angular2/core';
@Directive({
    selector: …
Run Code Online (Sandbox Code Playgroud)

mathjax angular2-directives angular

8
推荐指数
1
解决办法
5665
查看次数

基于子域的Angular2路由?

我正在尝试根据 URL 中的子域在 Angular2 路由器中进行路由。例如,如果有人请求 test.domain.com,那么他们会得到“test”路由。我无法在不设置超时延迟的情况下让 router.navigate 从 ngOnInit 工作,但是从构造函数运行以下内容是可行的。如果有更清洁的解决方案会感兴趣吗?

{path: 'test',                    component: TestComponent}

this._router.events.subscribe(event => {
 if (event.constructor.name === 'NavigationEnd'
     && window.location.hostname == 'test.domain.com'
     && event.url == '/') {
       console.log(event.url);
       this._router.navigate(['test']);
     }
 });
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular

3
推荐指数
2
解决办法
8158
查看次数

AbstractProvider.php第134行中的Laravel 5.2/Socialite FatalErrorException:

使用Socialite通过Facebook进行身份验证时出现以下错误.使用Laravel 5.2,这是我第一次尝试实现Socialite.有任何想法吗 ?

FatalErrorException in AbstractProvider.php line 134:
Call to a member function set() on a non-object
Run Code Online (Sandbox Code Playgroud)

路线: -

Route::get('/login', 'AuthController@login');
Run Code Online (Sandbox Code Playgroud)

AuthController.php: -

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class AuthController extends Controller
{
public function login()
{
  return \Socialite::with('facebook')->redirect();
}
}
Run Code Online (Sandbox Code Playgroud)

services.php设置如下.env文件中的详细信息: -

'facebook' => [
    'client_id'     => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect'      => env('FACEBOOK_REDIRECT'),
],
Run Code Online (Sandbox Code Playgroud)

这里报告了同样的错误但没有回复: - https://laracasts.com/discuss/channels/laravel/laravel-socialite-session-errors-in-52/replies/125233

php oauth-2.0 laravel laravel-5

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