簡體   English   中英

如何在Ember中構建時區檢查應用程序

[英]How do I structure a Timezone Checking App in Ember

作為學習Ember的一種方法,我正在嘗試構建一個簡單的應用程序,現在沒有教程的內容。

該應用將執行以下操作-

  • 用戶寫自己的城市
  • 用戶寫他想見面的人的城市
  • 功能會一直備份,這對彼此都有利。 就是說,他們倆都不必太早醒來就不能再呆太晚)

我對如何以Ember方式構造數據有些困惑。 我將如何處理?

我在想 -

將有一個index.handlebars-這將具有個人A和個人B的城市的2個輸入字段-這將由“會議”模型支持(屬性:cityA,cityB)

單擊提交按鈕后,我很困惑-

我可以想象有一個名為MeetingTime的模型(包含personA的時間和personB的時間)。

遵循Ember的最佳做法,我將以何種方式提出這一點? 什么路線,控制器,模板等?


目前,這就是我所擁有的->

RightTime.Router.reopen({
  location: 'history'
});

RightTime.Meeting = DS.Model.extend({
  myCity: DS.attr('string'),
  theirCity: DS.attr('string'),

  meetingTimes: function() {
    if (myCity && theirCity) {
      // get back a collection of meeting times
    }

    return false;
  }.property('myCity','theirCity')
});

RightTime.IndexRoute = Ember.Route.extend({
  model: function() {
    //return this.store.createRecord('meeting');
    //the above return is giving the error 'unedfined is not a function'
  }
});

#index.handlebars
<div class="container">
  <div class="col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4">
    <header class="animated fadeInDown">
        <h1><span class="twenty-four-header">24</span>Time</h1>
        <h3>Get Great Meeting Times Instantly</h3>
    </header>
    <section class="main-options animated fadeInDown">
      <div class="form-group">
        {{input value=myCity placeholder="What's your city?" class="form-control input-lg"}}
      </div>
      <div class="form-group">
        {{input value=theirCity placeholder="What their city?" class="form-control input-lg"}}
      </div>
      <div class="form-group">
        <button {{action 'getTimes'}} class="btn btn-lg get-times btn-block btn-primary">Get Times!</button>
      </div>
    </section>
  </div>
</div>

最終成功了! www.24time.co

可以在www.github.com/stopachka/right-time上找到該代碼。

有一種稱為會議的模型。

人們通過與Places Autocomplete API進行交互來選擇城市。 當他們選擇時,它將返回latLng職位,這些職位已附加到會議中。 一旦模型同時具有城市的兩個位置,它就會向/ api / meeting發出ajax請求,並發送位置參數。

API返回所有最佳時間。 我很確定我不是在做余燼游戲,也許可以對模型進行不同的分解,而且時間可以是模型本身。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM