我无法理解我的代码出了什么问题,我导入了模块,但仍然收到此错误“未找到名称‘matAutocomplete’导出”
注意:导入MatAutocompleteModule后,我重新启动IDE再次编译几次,仍然一样。
这是 app.module.ts - 仅粘贴代码的相关部分
import {MatAutocompleteModule} from '@angular/material/autocomplete';
@NgModule({ declarations:[..xxxx....],
imports:[xx,xxx,MatAutocompleteModule],
providers:[xx,xx],
bootstrap: [AppComponent]})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
组件.html
<form class="form-group-parent p-0" [formGroup]="frmStep1" (ngSubmit)="submit()">
<mat-form-field class="example-full-width">
<input type="text" placeholder="Ex. English" aria-label="Language" matInput
[formControl]="language" [matAutocomplete]="auto">
<mat-autocomplete autoActiveFirstOption #auto="matAutocomplete">
<mat-option *ngFor="let option of languageList | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
<mat-error>
<strong>Language</strong> is required.
</mat-error>
</mat-form-field>
</form>
Run Code Online (Sandbox Code Playgroud)
组件.ts
import {Component, OnInit} from '@angular/core';
import {FormControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from …Run Code Online (Sandbox Code Playgroud) 我有一个组件页面和相应的样式表,但是component.scss中的类不适用于该页面。没有错误,我仍然想知道为什么吗?
这是我的product-detailpage.component.html
<div>
<h1>Product Detail Page</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
这是.ts文件
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {ProductdetailService} from '../productdetail.service';
@Component({
selector: 'app-product-detailpage',
templateUrl: './product-detailpage.component.html',
styleUrls: ['./product-detailpage.component.scss']
})
export class ProductDetailpageComponent implements OnInit {
constructor(private route: ActivatedRoute, private productData: ProductdetailService) {
this.route.params.subscribe(params => console.log(params));
}
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
这是.scss文件
body{color:Red !important}
app-product-detailpage{
h1{color:red !important}
}
Run Code Online (Sandbox Code Playgroud)
但是我注意到的一件事是,如果我对global styles.css进行了更改,它就可以正常工作。只是检查一下,我将主体颜色更改为绿色,并且可以正常工作。
我的角度应用程序配置为可与scss一起使用。可能是什么原因?有人可以建议吗?
我试图实现一个简单的登录/注销功能。我的场景是这样的:
我有 2 个页面(登录页面和主页),在 中main.dart,我使用 SharedPreferences 检查用户是否已登录,如果用户已登录,我在单击按钮时将布尔值设置为 true。
我遇到的问题是,我创建了一个 routeLogin 函数,用于在主页和登陆页面之间进行选择。我得到这个错误:
I/flutter ( 9026): ??? EXCEPTION CAUGHT BY WIDGETS LIBRARY ????????????????????????????????????????????????????????????
I/flutter ( 9026): The following assertion was thrown building MyApp(dirty):
I/flutter ( 9026): type 'Future<dynamic>' is not a subtype of type 'bool'
I/flutter ( 9026):
I/flutter ( 9026): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 9026): more information in this error message to help you determine and …Run Code Online (Sandbox Code Playgroud) 我正在使用Ionic 2表单控件,只想验证表单。我收到此错误“ TypeError:无法读取未定义的属性'控件'”。
这是我的.html页面
<ion-header>
<ion-navbar>
<ion-row align-items-center>
<!-- <ion-col col2 align-items-center>
<ion-icon name="person" item-left></ion-icon>
</ion-col> -->
<ion-col col-12 align-items-center>
<h1>Personal Details</h1>
</ion-col>
</ion-row>
</ion-navbar>
</ion-header>
<ion-content padding>
<form class="spacingafterlogo" [formGroup]="authForm" (ngSubmit)="onSubmit(authForm.value)">
<ion-item>
<ion-label>Full Name:</ion-label>
<ion-input [formControl]="username" ([ngModel])="userName" placeholder=""></ion-input>
</ion-item>
<!-- <ion-item>
<ion-label>Birth Date:</ion-label>
<ion-input [formControl]="dob" ([ngModel])="userDob" placeholder=""></ion-input>
</ion-item>
<ion-item>
<ion-label>Gender:</ion-label>
<ion-input [formControl]="gender" ([ngModel])="userGender" placeholder=""></ion-input>
</ion-item>
<ion-item>
<ion-label>Email Id:</ion-label>
<ion-input [formControl]="email" ([ngModel])="userEmail" type="email" placeholder=""></ion-input>
</ion-item>
<ion-item>
<ion-label>Mobile:</ion-label>
<ion-input max="10" [formControl]="mobiile" ([ngModel])="userPhone" type="number" placeholder="Let's get in touch"></ion-input>
</ion-item>
<ion-item>
<ion-label>Address:</ion-label>
<ion-textarea …Run Code Online (Sandbox Code Playgroud) 我有一个登录页面和一个主页.我使用本机存储来设置项目,该项目将检查用户是否已登录(Facebook或Google身份验证).如果该项具有值(此检查发生在app.componenet.ts中),则会直接导航到主页.一旦用户登录并且如果恰好最小化应用程序并且在一段时间之后.当用户再次打开应用程序时,在加载几秒后,我会看到登录屏幕(用户已经登录时不应该看到)1秒钟,然后导航到主页.
这是我的app.component.ts
import { Component, ViewChild } from '@angular/core';
import { Platform, Nav, AlertController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { LoginPage } from '../pages/login/login';
import { NativeStorage } from '@ionic-native/native-storage';
import { TabsPage } from '../pages/tabs/tabs';
import { Facebook } from 'ionic-native';
import { GooglePlus } from '@ionic-native/google-plus';
@Component({
templateUrl: 'app.html',
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = LoginPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, …Run Code Online (Sandbox Code Playgroud) 我正在使用Ionic文档中指定的Native Storage插件,但是当我在设备或模拟器上部署时,我得到一个白色屏幕.在将其连接到chrome> Remote Devices> Inspect后进一步检查时.在控制台中我得到此错误 错误错误:没有NativeStorage的提供程序!
有什么指针吗?请帮忙
下面是我的错误日志:
NativeStorage!
at Error (native)
at injectionError (file:///android_asset/www/build/main.js:1509:86)
at noProviderError (file:///android_asset/www/build/main.js:1547:12)
at ReflectiveInjector_._throwOrNull (file:///android_asset/www/build/main.js:3048:19)
at ReflectiveInjector_._getByKeyDefault (file:///android_asset/www/build/main.js:3087:25)
at ReflectiveInjector_._getByKey (file:///android_asset/www/build/main.js:3019:25)
at ReflectiveInjector_.get (file:///android_asset/www/build/main.js:2888:21)
at NgModuleInjector.get (file:///android_asset/www/build/main.js:3835:52)
at resolveDep (file:///android_asset/www/build/main.js:11202:45)
at createClass (file:///android_asset/www/build/main.js:11071:32)View_MyApp_Host_0 @ ng:///AppModule/MyApp_Host.ngfactory.js:6
Run Code Online (Sandbox Code Playgroud)
这是我的版本信息:
cordova CLI: 6.5.0
Ionic Framework Version: 3.2.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.7
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.0
Xcode …Run Code Online (Sandbox Code Playgroud) 我正在尝试建立一个列表(一种您在 Facebook 上看到的通知系统)。该列表使用 JSON 获取,并由 ngFor 在 UI 上生成。我有一个默认的 css 类(来自 JSON 的未读)应用于它。我希望根据任何事件动态更改 DOM 上的该类(现在假设底部有一个按钮)。所以基本上我会生成很多 DIV,除此之外,我只需要在一些嵌套的 span 标签上更改 css 类。
我可以为跨度分配一个唯一的 ID,所以基本上我如何使用 Angular 2 定位这些跨度并更改 css 类。
关于如何去做的任何指示?我正在尝试使用 Angular 2 来实现。使用普通的 javascript 或 jquery 将是我最后的手段。
这是我的 HTML:
<ion-row *ngFor="let m of messages">
<ion-col col-12 >
<div class="talk-bubble border" [ngClass]="[m.position]">
<span class="talktext">{{m.message}}</span>
<span #elem [attr.id]="m.iconId" class="message-status" [ngClass]="[m.status]" ></span>
<span class="datedisplay">{{m.date}}</span>
</div>
</ion-col>
</ion-row>
Run Code Online (Sandbox Code Playgroud)