动态元素上添加指令,这并不尚不存在

编程入门 行业动态 更新时间:2024-10-23 21:39:49
本文介绍了动态元素上添加指令,这并不尚不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用这个插件来引导我与angularJS下拉列表。我遇到的问题是,他们想要的code相的东西。

I'm using this plugin to bootstrap my dropdown with angularJS. The issue I'm having is that the code they want looks something to

<ol class="nya-bs-select" ng-model="City" name="city" required> <li nya-bs-option="city in subCities "> <a>{{ city.name }}</a> </li> </ol>

来产生类似

<ol ng-model="City" class="nya-bs-select ng-pristine ng-untouched btn-group ng-invalid ng-invalid-required"> <button type="button" class="btn btn-default dropdown-toggle"><span class="pull-left filter-option">- Select -</span>&nbsp;<span class="caret"></span></button> <div class="dropdown-menu open"> <ul class="dropdown-menu inner"> <li><a>- Select -</a></li> <li nya-bs-option="city in subCities" class="ng-scope nya-bs-option"> <a tabindex="0" class="ng-binding">CityName</a> </li> </ul> </div> </ol>

正如你可以看到它增加了一个按钮元素为&LT的子女; OL&GT; 。我怎么能听为nyaBsSelect指令,这样,当它创建&LT;按钮&GT; 元素,我想添加一个 NG-禁用指令作为按钮的属性?

As you can see it adds a "button" element as a child of <ol>. How can I "listen" for the "nyaBsSelect" directive so that when it creates the <button> element, I want to add a ng-disabled directive as the button's attribute?

推荐答案

您可以为NYA-BS-选择相同的元素增加一个指令。该指令可以找到按钮添加属性。然而,当你想添加一个指令,因为属性你可能要做$添加属性按​​钮后的编译。让你的指令插件指令之后执行,您可以修改的优先级。我没有看过成插件。我想你也可以修改插件来添加更多的属性和NG禁用按钮,结合两者。

You can add one more directive in the same element as nya-bs-select. That directive can find the button and add the attribute. However as you want to add a directive as attribute you might have to do $compile of button after adding the attribute. You can modify priority so that your directive executes after plugin directive. I have not looked into the plugin. I guess you could also modify the plugin to add one more attribute and ng disabled to button and bind both.

更多推荐

动态元素上添加指令,这并不尚不存在

本文发布于:2023-10-16 00:20:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1495912.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:尚不   指令   这并   元素   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!