Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Can’;t解析组件的所有参数:(?)Ionic2 RC4_Angular_Ionic2 - Fatal编程技术网

Angular Can’;t解析组件的所有参数:(?)Ionic2 RC4

Angular Can’;t解析组件的所有参数:(?)Ionic2 RC4,angular,ionic2,Angular,Ionic2,亲爱的, 我知道这个问题反复出现,但实际上我尝试了所有可用的解决方案,但仍然无法解决我的问题。 我有多个组件和一个服务,我将该服务导入到signin、signup等组件中。 但我有一个组件导致了这个问题,如果我从it中删除服务注入,应用程序将运行得非常完美 无效组件是: 激活 import {Component,Injectable,Inject} from '@angular/core'; import {CloudAuth} from '../../shared/auth_service';

亲爱的, 我知道这个问题反复出现,但实际上我尝试了所有可用的解决方案,但仍然无法解决我的问题。 我有多个组件和一个服务,我将该服务导入到signin、signup等组件中。 但我有一个组件导致了这个问题,如果我从it中删除服务注入,应用程序将运行得非常完美

无效组件是:

激活

import {Component,Injectable,Inject} from '@angular/core';
import {CloudAuth} from '../../shared/auth_service';
@Component({
  selector: 'page-activation',
  templateUrl: 'activation.html'
})
export class Activation   {
  constructor( @Inject(CloudAuth) public _CloudAuth:CloudAuth ){

  }
}
其中一个工作组件login.ts

import {Component} from '@angular/core';
import {NavController, NavParams, LoadingController, AlertController, AlertOptions, Platform} from 'ionic-angular';
 import {FormBuilder, Validators, FormGroup} from '@angular/forms';
import {TranslateService} from "ng2-translate";

import {Facebook} from 'ionic-native';
 import {CloudAuth} from '../../shared/auth_service';


@Component({
  selector:'page-login',
  templateUrl: 'login.html',
})
export class login {

  constructor(public loading: LoadingController, public navCtrl: NavController, public params: NavParams,
              public _userService: UserService, public _FormBuilder: FormBuilder, public translate: TranslateService,
              public alertCtrl: AlertController , public _CloudAuth:CloudAuth) {
 ........... 
  }
 ...........

}
我的服务代码是auth_service.ts:

import {Injectable , Inject} from "@angular/core";
import { Platform } from 'ionic-angular';
import "rxjs/add/operator/map";
import { JwtHelper } from 'angular2-jwt';
import {TranslateService} from 'ng2-translate/ng2-translate';

import {Activation} from '../user/activation/activation';
import {welcomePage} from '../welcome/welcome';
import {userLogin} from '../user/user';
import {CompleteRegistration} from '../user/completeRegistration/completeRegistration';
import {HomePage} from '../home/home';

@Injectable()
export class CloudAuth {

  jwtHelper: JwtHelper = new JwtHelper();
  token=null;
  constructor(
    @Inject(TranslateService) public translate: TranslateService , 
    @Inject(Platform)  public platform: Platform
  ){
          this.token = localStorage.getItem('user_token');
  }

      getToken(){
        return this.token;
      }
      updateToken(newtoken){
        localStorage.setItem('user_token', newtoken.toString());
        this.token = newtoken;
        return true;
      }
      isTokenExpired(){
          // Check if token expired
          return this.jwtHelper.isTokenExpired(this.token)
      }
      tokenData(){
         // Return data stored in token
          if(this.token=='' || this.token == null) return false;
          else return this.jwtHelper.decodeToken(this.token);
       }

       checkCode(code){
          let userData =  this.tokenData();
          if( userData == false) return false;
          else {
              if(userData.activation_code == code) return true;
              else return false; 
          }
       }

      // Check if user login or not and loading the default app Language.
      checkLogin():any{
        console.log(this.token);
        let lang = localStorage.getItem('Language');
        if(!lang || lang==''|| lang === undefined ) return welcomePage;
        else {
          if(lang=='ar'){
                this.platform.setLang('ar',true);
                this.platform.setDir('rtl',true);
          }
          this.translate.use(lang);
          let userData =  this.tokenData();
          if( this.token==null ||  this.token== '' || userData == false) return userLogin;
          else {
              if(userData.active == 1) {
                  if(!localStorage.getItem('firstRun') ){
                    return CompleteRegistration;
                  }else{
                    return HomePage;
                  }
              }else {
                  return Activation;
              }
          }
        }
      }
}
我删除了@InjectDecorator,但也不起作用

My package.json是:

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.6",
    "angular2-jwt": "^0.1.25",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.2.11",
     "ionicons": "3.0.0",
    "ng2-translate": "^4.0.1",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.47",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "ios",
    {
      "platform": "ios",
      "version": "",
      "locator": "ios"
    }
  ],
  "description": "pecardPlayground: An Ionic project"
}
我的节点和信息是:

Ionic Framework: 2.0.0-rc.4 
Ionic Native: 2.2.11 
Ionic App Scripts: 0.0.47 
Angular Core: 2.2.1 
Angular Compiler CLI: 2.2.1 
Node: 6.7.0 
OS Platform: macOS Sierra
自从升级到Ionic RC4后,此错误在发生之前不会出现 希望找到解决办法。
谢谢

您似乎遇到了循环依赖的情况。 您已在
auth\u服务
中导入
激活
组件,并已导入
auth_服务
Activation
中,这是您的起始页。 使用

在激活中的构造函数中。 另一个教程链接

编辑:
如果可能的话,也可以重新考虑设计。

你能在你的身份验证服务中包含package.jsontanks@SurajRao吗?我用package.json文件更新了这个问题,本地存储集在哪里?是的,我没有使用离子存储。只需本地存储。它还可以与其他组件配合使用
constructor(@Inject(forwardRef(() => CloudAuth)) _CloudAuth)