我正在尝试使用 Angular 4 实现登录功能,但是当我使用 canActivate Guard 时,它会导致我进入空白页面,请帮助我
这是我的登录服务
isAuthenticated(){
return localStorage.getItem('token') != null ;
}
Run Code Online (Sandbox Code Playgroud)
这是可以激活守卫的
canActivate(route : ActivatedRouteSnapshot , state : RouterStateSnapshot){
return this.loginservice.isAuthenticated();
}
Run Code Online (Sandbox Code Playgroud)
这是路由器模块
const appRoutes: Routes = [
{path : '' , redirectTo:'/login', pathMatch :'full' },
{path : 'login' , component : LoginComponent },
{path : 'home' , component : HomeComponent, canActivate : [AuthGuard] ,children :[
{path : 'adduser' , component : AdduserComponent },
]
Run Code Online (Sandbox Code Playgroud) 我想在 ionic 3 中进行批量插入我有这个代码它可以工作但它真的很慢
insertQuotation(value){
for(var i=0; i<=value.length; i++){
let data=[value[i].quotation_id,value[i].customer_name,value[i].product_name,value[i].price,value[i].services,value[i].response_time,value[i].created_time];
this.database.executeSql("insert into care_plan_quotation_history(care_plan_quotation_id,customer_name,product,price,services,response_time,created_time) values(?,?,?,?,?,?,?)",data)
.then(data=>{
return data;
},err=>{
alert("error");
})
}
}
Run Code Online (Sandbox Code Playgroud)
请在这件事上给予我帮助