實務練習

  • 實作購買超過 5 張自動打 95 折

app.controller('main', function () {
  var self = this;
  self.location = '里斯本';
  self.quantity = 1;
  self.price = 1000;
  self.subtotal = function() {
    var discount = 1;

    if(self.quantity > 5) {
        discount = 0.95;
    }

    return self.quantity * self.price * discount;
  };
});

JS Bin

  • 實作訂購機票,準備一份假資料 Model 呈現在 View。

JS Bin

results matching ""

    No results matching ""