大家好,这是我在我网站上登录的代码。 我的代码工作,但我有重定向到另一个HTML页面的问题。 我有此错误消息
NullInjectorError:没有路由器的提供商!
导入项目:
import {Component} from '@angular/core';
import {requestService} from '../request.service';
import {functionComponent} from '../function.component';
import {CookieService} from 'ngx-cookie-service';
import {Router, Routes} from '@angular/router';
装饰
@Component({
selector: 'login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css'],
})
我的行动代码:
export class LoginComponent {
email: string;
password: string;
getStructure: object;
getData: object;
constructor(
private request: requestService,
private callFunction: functionComponent,
private cookie: CookieService,
public router: Router
) {}
login() {
this.getStructure = this.callFunction.getBasicLogin(this);
this.request.getRequest(this.getStructure).subscribe(
data => {
console.log(data);
// this.getData = data.Authentication.AccessToken;
console.log(data.Authentication.AccessToken)
if (data.Authentication.AccessToken) {
console.log('Hello')
this.cookie.set('AccessToken', data.Authentication.AccessToken);
console.log(this.cookie.get('AccessToken'));
}
else {
console.log('Exit')
}
}
);
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
//import {Router} from'@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import {CookieService} from 'ngx-cookie-service';
import { AppComponent } from './app.component';
import { ProductComponent } from './product/product.component';
import {requestService} from './request.service';
import {functionComponent} from './function.component';
import { LoginComponent } from './login/login.component';
部分NgModel
@NgModule({ 声明:[ AppComponent, ProductComponent, LoginComponent, // functionComponent
],
imports: [
BrowserModule,
FormsModule,
CommonModule,
HttpClientModule,
],
providers: [requestService, functionComponent, CookieService],
bootstrap: [AppComponent]
})
export class AppModule {}
答案 0 :(得分:0)
很可能您只是没有将路径导入主模块:
echo "Enter username for LDAP Search"
read USERNAME
export USERNAME
echo "Enter password"
read -s PASSWORD
export PASSWORD
echo "What user do you want to add to Centrify?"
while IFS='' read -r line || [[ -n "$line" ]]; do
read CENTRIFY_USER
export CENTRIFY_USER
OBJECTSID=`ldapsearch -H ldap://my.domain.com:389 -D "$USERNAME@MY.DOMAIN.COM" -w $PASSWORD -x -b "DC=my,DC=domain,DC=com" "(&(objectCategory=user)(sAMAccountName=$CENTRIFY_USER))" | grep objectSid | cut -d " " -f2`
SID=`/home/myhome/convert_objectSid_to_sid.sh $OBJECTSID`
export SID
echo "Adding user to Centrify..."
/home/myhome/add_users_to_centrify.sh
done < centrify_users_to_add.txt
AppRoutes是您定义的路线(路径等)