使用AngularJS有条件地隐藏可编辑文本属性 [英] Hide editable-text attribute conditionally using AngularJS

查看:53
本文介绍了使用AngularJS有条件地隐藏可编辑文本属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将X-Editable与AngularJS用于表格

I am using X-Editable with AngularJS for Form

<form editable-form name="userform" onaftersave="submitUser()">
                    <table class="user_table">
                        <tr class="userrow name">
                            <td class="info">First Name</td>
                            <td class="desc">
                                <span editable-text="curuser.firstName" e-name="firstName" e-maxlength="25">{{curuser.firstName}}</span>
                            </td>
                        </tr>
                        <tr class="userrow email">
                            <td class="info">E-Mail</td>
                            <td class="desc">
                                <span editable-email="curuser.email" e-name="email" e-maxlength="48">{{curuser.email}}</span>
                            </td>
                        </tr>
                        <tr class="userrow authority">
                            <td class="info">Role</td>
                            <td class="desc user-roles">
                                <span editable-select="roleUpdated" e-name="roles" e-ng-options="role as role.name for role in roles" onaftersave="updateRole(curuser, roleUpdated)">{{ showRoles() }}</span>
                                    {{ showRoles() }}
                                </span>
                            </td>
                        </tr>
                        <tr ng-if="curuser.id == null" class="userrow command">
                            <td class="info"></td>
                            <td class="desc">
                                <button type="submit" class="submit_button btn btn-primary" ng-show="!readonly && !amanager">Submit</button>
                            </td>
                        </tr>
                    </table>
                </form>  

有两个条件,一个条件应允许用户更新所有字段,而另一个条件则应允许用户仅编辑角色,即选择角色.
我的实际问题是如何根据特定条件使表格元素可编辑/不可编辑.如果我从所有字段中手动删除可编辑文本,则它满足第二个条件.有什么方法可以根据条件添加可编辑文本.
任何人有任何有用的想法吗?

There are two criteria, one wherein user should be allowed to update all fields and other where in user will be allowed only to edit role i.e. Select Role.
My actual problem is that how can form elements be made editable/non-editable based on a specific condition. If I remove editable-text manually from all fields it satisfies second criteria. Is there any way I can add editable-text based on condition.
Anyone have any helpful ideas?

预先感谢

推荐答案

我知道已经很晚了,但我自己也遇到了同样的情况

I know that's late but I've faced the same myself

例如,假设您不希望修改电子邮件,除非电子邮件是默认电子邮件

for example let's say you don't want to allow modification of e-mail unless the e-mail is the default one

<span editable-email="curuser.email" e-name="email" e-maxlength="48" ng-if="curuser.email=='Enter an e-mail'">
{{curuser.email}}
</span>

<span e-name="email" e-maxlength="48" ng-if="curuser.email != 'Enter an e-mail'">
{{curuser.email}}
</span>

那只是一个例子,但我敢肯定,您可以激发自己的灵感

that's just an example but i'm sure you can inspire yourself

这篇关于使用AngularJS有条件地隐藏可编辑文本属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆