带环路的离子2离子无线电误差

时间:2017-01-26 07:23:56

标签: angular typescript ionic-framework ionic2

我在离子2离子收音机方面遇到了麻烦。

这个想法是:组件从使用HTTP的服务获取数据,并将值分配给symb = re.match(r'"(.*?)"', line) #line is the line of string if symb is not None: print(symb.group(1)) print() else: print("No Match") print() date = re.match(r'".+?(\d+/\d+/\d+)"', line) if date is not None: print(date.group(1)) print() else: return print("No Match") print() time = re.match(r'".+?(\d+:\d+[a-z]{2})"', line) if time is not None: print(time.group(1)) print() else: print("No Match") print() #lastPrice = The first number after the time lastPrice = re.match(r'.+?(\d+\.\d{2}?),', line) if lastPrice is not None: print(lastPrice.group(1)) print() else: print("No Match") print() 中的data属性,但无法选择单选按钮。

模板:

ngOnInit

组件:

<ion-list class="rooms" padding radio-group>
    <ion-item *ngFor="let r of data?.rooms">
       <ion-label >{{ r?.name }}</ion-label>
       <ion-radio checked="{{ selectedRoom == r?.id }}" value="{{ r?.id }}"></ion-radio>
    </ion-item>
</ion-list>

编辑: 这只是我的代码中的插值问题。只需更改模板。 import { Component, OnInit } from '@angular/core'; import { NavController, NavParams } from 'ionic-angular'; import { BookConfirmPage } from '../bookconfirm/bookconfirm'; import { RoomDetailPage } from '../roomdetail/room'; import { HotelService } from '../../providers/hotel/hotelservice'; @Component({ selector: 'page-hotel-detail', templateUrl: 'hotel.html', providers: [HotelService] }) export class HotelDetailPage implements OnInit { public data; public selectedRoom: number; constructor( private navCtrl: NavController, private hotelServ: HotelService, private navParams: NavParams ) { } ngOnInit(): void { // u need a interface to make data readable and consistent. // this really unrecomended. for learn only. let id = this.navParams.get('id'); let idRoom = this.navParams.get('idRoom'); this.hotelServ.get(id).then(res => { this.data = res; //console.log(res); }) .catch(err => console.log(err)); this.selectedRoom = idRoom; } showBookConfirm(id) { console.log(this.selectedRoom) this.navCtrl.push(BookConfirmPage, { 'id': id }); } showRoomDetail(id) { this.navCtrl.push(RoomDetailPage, { 'id': id }); } }

1 个答案:

答案 0 :(得分:0)

只需更改

<ion-list class="rooms" padding radio-group>
  <ion-item *ngFor="let r of data?.rooms">
    <ion-label >{{ r?.name }}</ion-label>
    <ion-radio checked="{{ selectedRoom == r?.id }}" value="{{ r?.id }}"></ion-radio>
  </ion-item>
</ion-list>

<ion-list class="rooms" padding radio-group [(ngModel)]="selectedRoom">

  <ion-card class="room-card" *ngFor="let r of data?.rooms">
    <ion-card-content>
      <div class="left">
        <ion-radio [value]="r?.room_id"></ion-radio>
      </div>
      <div class="right" (click)="showRoomDetail(r?.room_id)">
        <ion-card-title>
          {{ r?.name }} {{ r?.room_id }}
        </ion-card-title>
        <p color="warning">&nbsp;Rp. {{ r?.cost }}</p>
      </div>
    </ion-card-content>
  </ion-card> 

</ion-list>

导致这只是插值问题,不是来自离子而是来自我的代码