【发布时间】:2016-12-05 14:46:44
【问题描述】:
您好,我已经被一个问题困扰好几天了,到目前为止,还没有任何研究证明是足够的。我正在尝试在 Ionic 2 中创建一个具有特定类(或 id)的简单模式。
我需要这么简单的东西:
<ion-modal class="myDifficultToAddClass">
...
</ion-modal>
这是我的代码:
import { NavParams, ModalController } from 'ionic-angular';
@Component(...)
class PageBehindTheModal {
constructor(public modalCtrl: ModalController) {
}
presentProfileModal() {
let profileModal = this.modalCtrl.create(Profile, { randomData: randomData });
profileModal.present();
}
}
@Component(...)
class Profile {
constructor(params: NavParams) {
console.log('Some info: ', params.get('randomData'));
}
}
我尝试使用 angular/core 中的 ViewEncapsulation 封装视图,以便使用本地 css,但是这个 css 将在全球范围内可用(我不能只“设置”这个特定的模式 - 所以这不是一个解决方案) :
import { ViewEncapsulation } from '@angular/core';
@Component({
styleUrls: ['./product-details.scss'],
encapsulation: ViewEncapsulation.Emulated
})
我希望找到一个简单的解决方案,例如:
// create(component, data, opts)
create(Profile, { randomData: randomData }, { cssClass: 'myDifficultToAddClass' })
很遗憾,我的愿望没有实现:)。
有人知道怎么做吗?
【问题讨论】:
标签: javascript angular ionic2