【问题标题】:Angular form inside directive with isolated scope具有隔离范围的指令内的角度形式
【发布时间】:2015-02-02 07:31:59
【问题描述】:

我有这样的表格

<ng-form name="investorQuestionaireForm" ng-show="user && user.investorType">
    <input 
        type="radio" 
        required
        name="recesso" 
        ng-model="investorQuestionaire.recesso" 
        ng-change="investorQuestionaireValidation('recesso', investorQuestionaireForm)"/> 
    <input 
        type="radio" 
        required
        name="recesso" 
        ng-model="investorQuestionaire.recesso"
        ng-change="investorQuestionaireValidation('recesso', investorQuestionaireForm)"/>
</ng-form>

此表单在指令内:

angular.module('crowdcoreApp').directive('investorForm',function(){
    templateUrl: 'views/template/equity_investor_form.html',
    restrict: 'E',
    scope: {
        project: '=project'
    },
});

我面临的问题是,当我单击单选按钮时,investorQuestionaire.recesso 的值没有更新,ng-change 函数没有被触发,最重要的是radio 按钮,仍然导致原始(在 html 类和指令范围内)。我认为数据绑定存在一些问题...

对这种行为的可能错误有何建议?

【问题讨论】:

    标签: javascript angularjs binding angularjs-directive scope


    【解决方案1】:

    您的单选按钮似乎没有值。

    为您的单选按钮添加一些值,然后重试。例如

    <ng-form name="investorQuestionaireForm" ng-show="user && user.investorType">
    <input 
        type="radio" 
        required
        value="option1"
        name="recesso" 
        ng-model="investorQuestionaire.recesso" 
        ng-change="investorQuestionaireValidation('recesso', investorQuestionaireForm)"/> 
    <input 
        type="radio" 
        required
        value="option2"
        name="recesso" 
        ng-model="investorQuestionaire.recesso"
        ng-change="investorQuestionaireValidation('recesso', investorQuestionaireForm)"/>
    </ng-form>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-03
      相关资源
      最近更新 更多