小编kau*_*han的帖子

根据条件禁用输入

大家好,我有以下代码:

<table class="details-table" *ngIf="peop && peopMetadata">
    <tr *ngFor="let attribute of peopMetadata.Attributes">
        <td class="details-property">{{attribute.AttributeLabel}}</td>
        <td [ngSwitch]="attribute.AttributeType">
            <div *ngSwitchCase="'String'">
                <input matInput [(ngModel)] = "peop[attribute.AttributeKey]" />
            </div>
            <div *ngSwitchDefault>{{peop[attribute.AttributeKey]}
            </div>
        </td>
    </tr>
    <div>
        <button ng-click="">Submit</button>
    </div>
</table>
Run Code Online (Sandbox Code Playgroud)

我想根据属性值禁用输入,比如 peop[attribute.IsWritable]='false' 。我怎么能在这里做到这一点。任何帮助表示赞赏

html typescript angular

7
推荐指数
1
解决办法
1万
查看次数

在rails中使用Presenters

json = JSON.parse(response.body)
    @games = json['machine-games']

    paging = json['paging']
    if paging
      if paging['next']
        next_page_query = paging['next'].match(/\?.*/)[0]
      @next_page = "/machine_games/search#{next_page_query}"
    end

    if paging['previous']
      previous_page_query = paging['previous'].match(/\?.*/)[0]
      @previous_page = "/machine_games/search#{previous_page_query}"
    end
  end
Run Code Online (Sandbox Code Playgroud)

以上是来自控制器中show方法的一小段逻辑.如何将其移动到演示者,以便它可以保存machine_games JSON响应并提供访问游戏和下一页/上一页链接的方法(以及是否他们存在).{不熟悉使用演示者模式}

ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2

5
推荐指数
1
解决办法
3756
查看次数

如何在法拉第设置日志级别

我最近将我的http客户端切换到法拉第,一切都按预期工作.我有以下代码来创建连接:

@connection = Faraday.new(:url => base_url) do |faraday|
              faraday.use Custim::Middleware
              faraday.request :url_encoded             # form-encode POST params
              faraday.request :json
              faraday.response :json, :content_type => /\bjson$/
              faraday.response :logger
              faraday.adapter Faraday.default_adapter  # make requests with Net::HTTP
Run Code Online (Sandbox Code Playgroud)

法拉第记录器有助于打印控制台输出上的所有日志.但是我不想在控制台输出上打印所有日志级别.如何设置日志级别只打印说错误日志?.

我正在使用法拉第版0.8.9

ruby ruby-on-rails faraday

5
推荐指数
2
解决办法
7211
查看次数

如何切入awk

我有一个文件如下

100 sesCook=0ea4ce6259b087f5aec09934b3aab9fe4f0ee62d

100 sesCook=71e16fadaf9c5c57e7ef706a60f768bcffad7fc1

100 sesCook=a60cbaaed8349260783309a72c8bcdbd4d030255

100 sesCook=f8470d1272c4d9c1b69682260ed1b558c7a2dd55

101 sesCook=83b867a10e3d9d3b727d281548dcf6c29efb9382

101 sesCook=e7c4a834d57576d73e66883d7fbfbc8160125569
Run Code Online (Sandbox Code Playgroud)

我想要第一列原样.然而在第二列我想切割所有"sesCook=",只是有模式,例如:

100 0ea4ce6259b087f5aec09934b3aab9fe4f0ee62d

100 71e16fadaf9c5c57e7ef706a60f768bcffad7fc1

100 a60cbaaed8349260783309a72c8bcdbd4d030255

100 f8470d1272c4d9c1b69682260ed1b558c7a2dd55

101 83b867a10e3d9d3b727d281548dcf6c29efb9382

101 e7c4a834d57576d73e66883d7fbfbc8160125569
Run Code Online (Sandbox Code Playgroud)

我如何使用awk或cut做到这一点?

awk

4
推荐指数
1
解决办法
3005
查看次数

使用没有活动记录的will_paginate

主持人:

应用程序/主持人/ games_presenter.rb

class GamesPresenter

  attr_reader :games, :next_page, :previous_page

  def initialize json
    @games = json['machine-games']

    paging = json['paging']
    if paging && paging['next']
      next_page_query = paging['next'].match(/\?.*/)[0]
      @next_page = "/machine_games/search#{next_page_query}"
    end

    if paging && paging['previous']
      previous_page_query = paging['previous'].match(/\?.*/)[0]
      @previous_page = "/machine_games/search#{previous_page_query}"
    end
  end

end
Run Code Online (Sandbox Code Playgroud)

控制器动作:

def show
  # ...
  @presenter = GamesPresenter.new(json)
end
Run Code Online (Sandbox Code Playgroud)

观点:

<% @presenter.games.each do |game| %>
  ...
<% end %>

<%= link_to "Previous", @presenter.previous_page %>
<%= link_to "Next", @presenter.next_page %>
Run Code Online (Sandbox Code Playgroud)

并且为了告诉Rails加载apps/presenters /目录以及models /,controllers /,views /等,将其添加到config/application.rb:

config.after_initialize do |app|
  app.config.paths.add …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2

4
推荐指数
1
解决办法
2588
查看次数