等效于以下角度2中的代码

时间:2019-01-26 21:44:47

标签: angularjs angular ionic-framework

我无法从angularjs ad angular 2更新此代码,谢谢您的帮助

class MyMailer < ApplicationMailer
  default from: 'todd@myemail.com'
  include Reports::OrderReport

  def welcome_email
    email = params[:email]
    mail(to: email, subject: 'Welcome to My Awesome Site')
    sheet = Reports::OrderReport.new
    sheet.create_workbook
  end

end

class Reports::OrderReport
  require 'axlsx'
  attr_reader :shop, :order_workbook

  def initialize
    workbook_instance = Axlsx::Package.new
    @order_workbook = workbook_instance.workbook
  end

  def create_workbook
    order_workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
      sheet.add_row ["First Column", "Second", "Third"]
      sheet.add_row [1, 2, 3]
      sheet.add_row ['     preserving whitespace']
    end
    order_workbook.serialize("test_book.xlsx")
  end
end

1 个答案:

答案 0 :(得分:2)

您需要在组件中定义一个布尔变量,然后将结果分配给该变量,

hasVipAccess : boolean = false;

if (settings != null && settings.checkSubscriptionForVip === true) {
            this.user.hasVipAccess().then(function(access) {
               this.hasVipAccess = access;               
            });
          } else {
          this.hasVipAccess = access;
 }

但是,如果不需要设置布尔变量,只需返回结果