草庐IT

AT指令

全部标签

javascript - AngularJS - 我的指令下的 html 没有显示

PleaseseerelevantjsFiddle在此文件中,我有两个跨度“test1”和“test2”。跨度“test2”正在显示,但我的自定义指令“test1”下的跨度根本没有显示或被调用到页面中。为什么?test1test2Angular代码varapp=angular.module('HelloApp',[])app.directive('searchBar',function(){return{restrict:'AE',replace:true,template:'',link:function(scope,elem,attrs){elem.bind('keyup',fun

jquery - bxslider 指令抛出错误 `Uncaught TypeError: Cannot read property ' indexOf' of undefined`

我在我的应用程序中使用angularjs,我在其中为bxslider创建了一个指令。下面是指令代码:angular.module('sbAdminApp').directive('bxSlider',function(){return{restrict:"A",require:"ngModel",link:function(scope,element,attrs,ctrl){element.ready(function(){$($(element[0])).bxSlider({maxSlides:1,auto:true,controls:false,pager:true});})}}}

javascript - Angularjs-阅读更多自定义指令不适用于 ng-bind-html 指令

这些是我的自定义指令,用于阅读更多内容和to_trusted(用于转换为html)。psp.directive('hmRead',function(){return{restrict:'AE',scope:{hmtext:'@',hmlimit:'@',hmfulltext:'@',hmMoreText:'@',hmLessText:'@',hmMoreClass:'@',hmLessClass:'@'},templateUrl:'partials/common/read-more.html',controller:function($scope){$scope.toggleValue

javascript - 使用 AngularJS 加载动态指令 - 错误 : Access to restricted URI denied

我目前正在使用HTML5、CSS、JS和AngularJS开发一个小型教育项目。问题:在我的index.html文件中加载AngularJS指令错误代码[1]-本地浏览器错误:访问受限URI被拒绝这个问题的一些答案,建议将项目部署在web服务器上。我做到了,错误很有趣:错误代码[2]-网络服务器加载资源失败:服务器响应状态为404(未找到)文件结构app/----app.js----components/----------view1/--------------fullView.html--------------fullViewApp.js--------------partial

javascript - AngularJS 指令需要监视两个属性

我正在用Angular制作游戏。每个播放器对象都有一个x和一个y属性。每当玩家移动时,我都想启动一个计时器,该计时器在Sprite表中的几个背景位置之间循环。我想我会用一个指令来做这件事。问题是指令通常只允许你设置一个表达式来观察://"test"directivemodule.directive("test",function(){returnfunction(scope,element,attrs){scope.$watch(attrs.test,function(value){//dosomethingwhenitchanges})}})//mytemplate这种方法的好处是,

javascript - AngularJS - 获取对象值的指令

目前我正在使用这个for循环来获取父级angular.forEach(queryTicketCategories,function(category){if(category.id===$scope.ticketCategory.parentId){$scope.parent=category;}});请建议将返回category的通用指令。这里queryTicketCategories是一个数组对象。我想为$scope.parent分配一个等于$scope.ticketCategory.parentId的数组HTML代码是 最佳答案

javascript - 无法从指令模板 Angular 访问模块

我正在尝试为ngAudio制作一个包装器组件,包装器本身将是带有控件的播放器-并将与ngAudio的功能进行交互。我遇到了一些范围问题,我可以将它注入(inject)组件的Controller并在那里访问ngAudio,但我无法从模板范围访问它。我试过使用$scope.ngAudio=ngAudio;之类的东西将ngAudio设置到作用域中,但无济于事-如果有人有任何想法,那就太棒了。我相信它需要某种双向绑定(bind)?或者以某种方式从指令级别访问ngAudio模块。代码:组件:.component('player',{//isolatedscopebinding bindings:

javascript - 将 ngModel 绑定(bind)到自定义指令

所以我已经在这个问题上工作了一个星期,我似乎无法理解整个指令的事情。看了很多帖子。。。DemystifyingDirectivesDirectivesCompile,PreandPostLinking一堆视频...CreatingReusableDirectivesinAngularJSWritingDirectives并浏览了StackOverflow和其他论坛(要遵循的链接),希望有什么东西会沉没......我认为我遇到的问题是我想了解这些为什么/如何工作,这样我就不会剪切/粘贴某人else的解决方案到我的代码中,但是当其他东西突然出现时不得不再次询问,因为我不知道我粘贴的代码在做

html - Zurb Foundation 6 视口(viewport)高度结束时的粘性开关状态 ".is-anchored .is-at-bottom"

尝试创建一个始终固定在网站顶部的菜单。遵循zurb.foundation的文档,但.sticky的行为总是出乎意料。或者也许我没有得到一些明显的信息?请在此处检查重建:http://codepen.io/mister-hansen/pen/wMgrPm如果网站向下滚动,并恰好达到初始视口(viewport)的高度,粘性插件会将元素.sticky从is-stuckis-at-top更改为:.is-anchored.is-at-bottom所以.sticky消失了。谢谢。更新文档的第一部分:foundation.zurb.com/sites/docs/sticky.html解释了所描述的行

javascript - 为什么我不能在 AngularJS 中使用 data-* 作为指令的属性名?

在thisplunker您会注意到指令中属性名称模式data-*的奇怪行为。电话:Testofdatanamedattribute:指令的:angular.module('apptest',[]).controller('Controller',['$scope',function($scope){$scope.vartest="Thisisatest";}]).directive('directivetest',function(){return{restrict:'E',scope:{dataTest:'=',test:'=',anotherTest:'='},templateUr