因此,我正在使用节点8.x运行ionic 4,试图将存储注入到应用程序中,以便可以从身份验证服务中检索令牌,但是出现以下错误:
StaticInjectorError(AppModule)[Storage]:
StaticInjectorError(Platform: core)[Storage]:
NullInjectorError: No provider for Storage!
at
Run Code Online (Sandbox Code Playgroud)
我读过其他关于相同问题的文章,但他们似乎有类型错误,我认为并非如此。
这是我的app.module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';
import { Storage, IonicStorageModule } from '@ionic/storage';
import { JwtModule, JWT_OPTIONS } …Run Code Online (Sandbox Code Playgroud) 我正在运行ionic 4应用程序
我创建了一个消息组件,该组件相应地加载了传递@Input给它的错误。
<control-messages [control]="saveUserForm.get('age')"></control-messages>
Run Code Online (Sandbox Code Playgroud)
因此它将加载FormControl验证并显示我在服务中定义的自定义消息;
我想知道的是,如果有某种方法可以向组件发送多个属性,我想<p class='help'></p>用success | warn | danger
这是组件:
@Component({
selector: 'control-messages',
template: `<p class="help" *ngIf="errorMessage !== null">{{errorMessage}}</p>`
})
export class ControlMessagesComponent {
@Input() control: FormControl;
constructor() { }
get errorMessage() {
for (const propertyName in this.control.errors) {
if (this.control.errors.hasOwnProperty(propertyName) && this.control.touched) {
return ValidationService.getValidatorErrorMessage(propertyName, this.control.errors[propertyName]);
}
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
我如何通过父级发送另一个参数以将其加载到模板中{{color}},如
template: `<p class="help {{color}}" *ngIf="errorMessage !== null">{{errorMessage}}</p>`
Run Code Online (Sandbox Code Playgroud)