gpt4 book ai didi

javascript - Angular JS 添加新行默认处于可编辑模式

转载 作者:行者123 更新时间:2023-12-03 05:48:42 24 4
gpt4 key购买 nike

我正在使用 ng-repeat 指令创建网格,但是通过单击新行,新行默认不处于可编辑模式,用户必须单击编辑按钮。如何在可编辑模式下创建新行?

    <!-- <tr ng-repeat="primaryskill in primarySkills"> -->
<tr ng-repeat="skill in skills">
<td>
<!-- <span editable-text="primaryskill.name" e-name="name" e-form="rowform"> -->
<span editable-text="skill.primarySkill.name" e-name="name" e-form="rowform">
{{ skill.primarySkill.name || 'empty' }}
</span>
</td>
<td >
<tags-input ng-model="skill.primarySkill.skillGroups" display-property="name" replace-spaces-with-dashes="false" on-tag-added="saveSkillGroup($tag,skill.primarySkill,$index)" on-tag-removed="removeSkillGroup(skill.primarySkill)">
<auto-complete source="loadskillGroups($query)" display-property="name" load-on-focus="true" min-length="0" load-on-empty="true"></auto-complete>
</tags-input>
<!-- <p>Model: {{skill.primarySkill.skillGroups}}</p> -->
</td>
<td>
<tags-input ng-model="skill.secondarySkills" display-property="name" on-tag-added="saveSecondarySkill($tag,$tag.id, skill.primarySkill)" on-tag-removed="removeSecondarySkill($tag,skill.secondary)">
<!-- <auto-complete source="loadsecondarySkills($query,skill.primarySkill.id)" display-property="name" min-length="0" load-on-empty="true"></auto-complete> -->
</tags-input>
<!-- <p>Model: {{skill.secondarySkills}}</p> -->
</td>

<td style="white-space: nowrap;text-align: center;" class="col-xs-12 col-xs-offset-3">
<!-- form -->
<form editable-form name="rowform" ng-show="rowform.$visible" class="form-buttons form-inline" onaftersave="savePrimarySkill(skill.primarySkill, $index)">
<button type="submit" ng-disabled="rowform.$waiting" class="btn btn-primary" >
save
</button>
<button type="button" ng-disabled="rowform.$waiting" ng-click="rowform.$cancel()" class="btn btn-default">
cancel
</button>
</form>
<div >
<div class="buttons" ng-show="!rowform.$visible">
<button class="btn btn-primary" ng-click="rowform.$show()">edit</button>
<button class="btn btn-danger" ng-click="removePrimarySkill(skill.primarySkill)">del</button>
</div>
</div>
</td>
</tr>
</table>

<div id="myprimarySkills">
<button class="btn btn-default" ng-click="addSkill(primaryskill)">Add Skill</button>
</div>
</div>

最佳答案

我相信您正在使用可xeditable 表单。只需尝试在表单元素上添加 shown="true"即可。

示例(只需尝试用此替换您的表单行):

<form editable-form name="rowform" shown="true" ng-show="rowform.$visible" class="form-buttons form-inline" onaftersave="savePrimarySkill(skill, $index)">

您也可以通过 ng-init 来完成:

<form editable-form name="rowform" ng-init="rowform.$show()" ng-show="rowform.$visible" class="form-buttons form-inline" onaftersave="savePrimarySkill(skill, $index)">

更新:

<form editable-form name="rowform" shown="skill.editable === true" ng-show="rowform.$visible" class="form-buttons form-inline" onaftersave="savePrimarySkill(skill, $index)">

$scope.addSkill = function (someParam) {
$scope.skills.push({
editable: true
//some other staff you're implementing
});
}

关于javascript - Angular JS 添加新行默认处于可编辑模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40236933/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com