我正在尝试实现HttpInterceptor.当我将其添加到@NgModule时,我在Chrome中收到以下错误:
Uncaught Error: Can't resolve all parameters for JwtInterceptor: (?, ?).
at syntaxError (compiler.js:466)
at CompileMetadataResolver._getDependenciesMetadata (compiler.js:15547)
at CompileMetadataResolver._getTypeMetadata (compiler.js:15382)
Run Code Online (Sandbox Code Playgroud)
花了很多时间在谷歌搜索,不知道该怎么做...
以下是我在AppModule中提供Interceptor的方法:
...
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: JwtInterceptor,
multi: true
}
],
...
Run Code Online (Sandbox Code Playgroud)
这是Interceptor本身,没什么特别的:
export class JwtInterceptor implements HttpInterceptor {
constructor(private inj: Injector, private logger: Logger) {
this.logger.l(true)('Interceptor >>');
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.logger.l(true)('interceptor >>');
const auth = this.inj.get(AuthService);
// add token to the request:
const authReq = req.clone({
setHeaders: {
Authorization: `Bearer ${auth.getToken()}`
} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用-aot
option(ng build -aot
)构建应用程序.我有以下错误:
ERROR in Error during template compile of 'MyComponent'
Function calls are not supported in decorators but 'classLogger' was called in 'cLog'
'cLog' calls 'classLogger'.
Run Code Online (Sandbox Code Playgroud)
但是,我需要这个调用,我不知道我应该如何更改代码以使其工作.
export function classLogger(_classOptions?) {
const myLogger = new MyLogger();
myLogger.options = Object.assign({}, defaultClassOptions, _classOptions);
return myLogger.loggerCB;
}
// export function clog(options = defaultClassOptions): Function {
export function cLog(options?): Function {
return loggingEnabled ? classLogger(options) : emptyClassDecorator();
}
Run Code Online (Sandbox Code Playgroud)
PS类装饰器采用必须转移到装饰器补丁回调的选项.
任何人都可以展示gulp-angular-filesort真正做什么以及如何正确使用它的例子吗?
问题是我最近意识到我的gulp -angular-filesort根本没有对angularjs文件进行排序,但是我的AngularJS App有很多文件可以正常工作.所以,我提出了两个问题:
我认为gulp-angular-filesort根据括号中指定的依赖关系查看angular.module语句和排序文件.看起来我错了.
请看下面的示例.
//文件:Gulpfile.js
'use strict';
var
gulp = require('gulp'),
connect = require('gulp-connect'),
angularFilesort = require('gulp-angular-filesort'),
inject = require('gulp-inject');
gulp.task('default', function () {
gulp.src('app/index.html')
.pipe(inject(
gulp.src(['app/js/**/*.js']).pipe(angularFilesort()),
{
addRootSlash: false,
ignorePath: 'app'
}
))
.pipe(gulp.dest('app'))
;
connect.server({
root: 'app',
port: 8081,
livereload: true
});
});
Run Code Online (Sandbox Code Playgroud)
//a_services.js
'use strict';
angular.module('myServices', [])
.factory('MyService', function () {
return {
myVar:1
};
})
;
Run Code Online (Sandbox Code Playgroud)
//b_controllers.js
'use strict';
angular.module('myControllers', ['myServices'])
.controller('MyController', function ($scope, MyService) {
$scope.myVar = …
Run Code Online (Sandbox Code Playgroud) 我遇到了使用anglular-cli ng-cli生成组件的问题,但没有将全新创建的组件添加到app模块:
$ ng g component Try
installing component
create src\app\try\try.component.css
create src\app\try\try.component.html
create src\app\try\try.component.spec.ts
create src\app\try\try.component.ts
update src\app\app.module.ts
No app module found. Please add your new class to your component.
Run Code Online (Sandbox Code Playgroud)
我没有移动任何文件.项目结构是默认的.的src\app\app.module.ts
存在,并且具有以下内容:
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {RouterModule} from '@angular/router';
import {AppComponent} from './app.component';
import {ROUTES} from "./app.routes";
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(ROUTES)
],
declarations: [
AppComponent
],
providers: [],
bootstrap: [AppComponent]
})
export …
Run Code Online (Sandbox Code Playgroud) 有没有办法为Response :: json()指定默认参数?问题是,在我的情况下,Response :: json($ data)返回utf8,因为我需要指定额外的参数才能读取它:
$headers = ['Content-type'=> 'application/json; charset=utf-8'];
return Response::json(Course::all(), 200, $headers, JSON_UNESCAPED_UNICODE);
Run Code Online (Sandbox Code Playgroud)
这很无聊,看起来多余......
我决定使用JWT并从项目中完全删除Laravel Passport.
我试着开始composer remove laravel/passport
.然而,它没有好处:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Laravel\Passport\Passport' not found
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Removal failed, reverting ./composer.json to its original content.
Run Code Online (Sandbox Code Playgroud)
什么是正确和安全的删除程序?
有谁知道如何在 Laravel 中使用 OUT 参数调用 MySQL 存储过程?
\n\n让\xe2\x80\x99s 说我有:
\n\nDB::statement('CALL sp_user_add(:name, :email, :password, :key, @res, @id);',\n array(\n $name,\n $email,\n $password,\n $key\n )\n);\n
Run Code Online (Sandbox Code Playgroud)\n\n如何获取@res
和的值@id
?
我正在尝试提交在几个子模块中所做的更改:
$ git submodule foreach git commit -m 'fixed header guards'
Entering 'libs/BaseDisplay'
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
fatal: run_command returned non-zero status for libs/BaseDisplay
.
Run Code Online (Sandbox Code Playgroud)
我看到进程在第一个最新的子模块上停止...但是,还有许多其他子模块具有暂存文件。如何使用唯一的命令提交在此类子模块中所做的更改?
lambda可以重复使用吗?我想把这个lambda称为几次.但我找不到给它命名的方法.
[]() { cout << "lambda is called"; };
Run Code Online (Sandbox Code Playgroud)
没有像这样调用lambda的目的是什么?编译器不会对上面的代码大喊大叫,但它没用.我对吗?
angular ×3
laravel ×3
angular-cli ×1
angularjs ×1
aot ×1
c++ ×1
composer-php ×1
decorator ×1
git ×1
gulp-inject ×1
lambda ×1
mysql ×1
php ×1