我无法调用超出范围的方法

时间:2019-01-31 22:54:17

标签: html typescript angular6 dxgrid

我有一列带有一个按钮,当该按钮被单击时会调用一个方法。这样,单击即可获得row对象,并提取需要调用另一个方法的属性。我不能调用reloadDialog它在我的组件中。这在DxGrid的列中。

  class AgentActivity < ApplicationRecord

  belongs_to :submission, :optional => true, inverse_of: 
  :agent_activities #has submission_id foreign key in table
   belongs_to :agent, :optional => true, inverse_of: :agent_activities 
  has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "100x100#" }, default_url: "/images/:style/missing.png"
   validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/

此buttonClickDetails和reloadDiaload位于同一组件中

create_table "agent_activities", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "Status"
t.text "Notes"
t.bigint "agent_id"
t.bigint "submission_id"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.index ["agent_id"], name: "index_agent_activities_on_agent_id"
t.index ["submission_id"], name: "index_agent_activities_on_submission_id"
end

1 个答案:

答案 0 :(得分:1)

确保已应用了文档给出的所有说明。在他们的示例中,他们向您展示了您需要像这样自己绑定上下文:

@Component(...)
export class MyComponent {

    constructor() {
        // binding 'this' will pass it as the context of that function.
        this.buttonClickDetails = this.buttonClickDetails.bind(this);
    }

    public buttonClickDetails(e: any) {
        console.log('inside button click details');
        const id = e.row.data.AgreementId;
        console.log('Leaving the buttonClickDetails');
        this.reloadDialog(id, 'Agreement');
    }
}

我从哪里获得的文档:Command Column Customization


我认为他们没有提供像(click)="buttonClickDetails($event)"这样的“正常” Angular输出事件方法真的很奇怪。不需要附加的绑定指令,但我想它就是它。