我正在我的 Ionic 4 项目中工作,并且创建了一个自定义组件,但在该自定义组件中我[(ngModel)]无法工作。
这是我的custom-header-component.component.html:
<ion-select [(ngModel)]="languageSelected" (ionChange)='setLanguage()' ngDefaultControl>
<ion-select-option value="en">English</ion-select-option>
<ion-select-option value="ar">Arabic</ion-select-option>
</ion-select>
Run Code Online (Sandbox Code Playgroud)
在此 html 中,my[(ngModel)]不起作用,因为它没有在控制台中打印任何值。
这是我的自定义标头组件.component.ts:
languageSelected: any;
setLanguage() {
let me=this;
console.log('languageSelected',me.languageSelected);
}
Run Code Online (Sandbox Code Playgroud)
在此 ts 文件中,它没有打印任何值。
也许问题是,我没有包含FormsModule.
这是我的文件夹:
custom-header-component:
|
-- custom-header-component.component.html
-- custom-header-component.component.scss
-- custom-header-component.component.spec.ts
-- custom-header-component.component.ts
components.module.ts
Run Code Online (Sandbox Code Playgroud)
这是我的Components.module.ts:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CustomHeaderComponentComponent } from './custom-header-component/custom-header-component.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [CustomHeaderComponentComponent],
exports: [CustomHeaderComponentComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA], …Run Code Online (Sandbox Code Playgroud) 我想bootstrap-notify在我的 Angular 7 应用程序中使用。
为此,我安装了该bootstrap-notify软件包(并且还安装了@types/bootstrap-notify)。
在我想要使用通知的组件中,我导入了 jQuery 服务,如下所示:
import * as $ from 'jquery';
Run Code Online (Sandbox Code Playgroud)
现在按照文档中的描述notify进行调用:
$.notify({
// options
message: 'Hello World'
},{
// settings
type: 'danger'
});
Run Code Online (Sandbox Code Playgroud)
问题是我收到此错误:
ERROR in src/app/home/home.component.ts(28,7): error TS2339: Property 'notify' does not exist on type 'JQueryStatic'.
Run Code Online (Sandbox Code Playgroud)
知道如何让它发挥作用吗?我找不到任何使用此包的 Angular (5/6/7) 示例!
我正在我的 Ionic 4 应用程序中工作,并且正在从 API 获取响应。我还将加载器添加到了首页,其中响应来自 API。
我想运行加载程序,直到不再从 API 获取响应为止。
这是我的tab1.page.ts:
import { Component, OnInit } from '@angular/core';
import { ChakapiService } from './../service/chakapi.service';
import { LoadingController, Events } from '@ionic/angular';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page implements OnInit {
detu: any;
newda: any;
constructor(public chakapi: ChakapiService, public loadingController: LoadingController, public events: Events,
private storage: Storage) {
this.detailsfetch('en');
}
ngOnInit() {
}
async detailsfetch($langselect) {
const loading …Run Code Online (Sandbox Code Playgroud) 我正在我的 Ionic 4 应用程序中工作,我已经使用循环添加了滑块,我正在检查滑块是否已到达最后一个滑块,并且我已经检查过使用,isEnd()但它始终显示 true。
这是我的intro.page.html:
<ion-slides #slides pager="true" parallax="true" spaceBetween="0">
<ion-slide class="step-one" *ngFor="let item of splashdata">
</ion-slide>
</ion-slides>
<p class="myp2" (click)="next()">{{ NextSlide }}</p>
Run Code Online (Sandbox Code Playgroud)
在此视图中,我在循环中显示滑块,还显示下一步和完成按钮。如果滑块到达最后一张幻灯片,它将显示完成,否则它将显示下一张。
这是我的intro.page.t:
export class IntroPage implements OnInit {
@ViewChild('slides') slides: IonSlides;
NextSlide: any;
constructor() { }
ngOnInit() {}
ionViewWillEnter(){
let me = this;
me.slides.isEnd().then((istrue) => {
console.log(istrue);
if (istrue) {
me.NextSlide = 'Finish';
} else {
me.NextSlide = 'Next';
}
});
}
next() {
this.slides.slideNext();
}
}
Run Code Online (Sandbox Code Playgroud)
在此 ts 文件中,我已使用进行了检查, …