所以我想显示,天气用户是活跃或不活跃。数据通过布尔形式的api传递。所以它会简单地说用户是真实的或者用户是假的。如果数据返回true,我想显示'Active',如果用户返回false,我想显示'Not Active'。解决方案我做了一个简单的工作,但这是在应用程序中重复使用,我想做一个角度过滤器来完成这项任务。 我是一个角度和Java脚本的初学者,并没有创建过滤器。用于从api返回true false的角度过滤器?
这是我的if else,并显示在HTML 它这个我我要如何使用eventuatlly
<label>{{ $ctrl.myValu | truefalse}}</label>
$onInit =() => {
let self = this;
this.siUser.current().then((userData) => {
let actingAsTenant = userData.user.apikey;
if (actingAsTenant) {
self.siTenant.current().then((tenant) => {
self.tenant = tenant;
///starts
if (self.tenant.active == true) {
self.tenant.active = 'Active'
}
else if (self.tenant.active == false){
self.tenant.active = 'Not Active'
}
//end
}, (err) => {
self.siAlertDialog.error(err.data.message)
})
}
}, (err) => {
self.siAlertDialog.error('Error rendering tenant details');
});
}
<strong>{{$ctrl.tenant.active}}</strong>
我想创建一个角度滤波器,所以它的可重复使用我的代码上面工作。所以我想创建一个true或false的过滤器,最终看起来像这样 –