jjzjj

Directive

全部标签

javascript - AngularJS - 包装指令

我似乎对指令中的孤立作用域感到困惑,希望你能帮助我。我试图将一段代码(其中包含一些自定义指令)包装到一个新指令中以减少代码重复。显然,我需要将一些属性(如ng-model)作为参数添加到我的新指令中,以使该指令可重用。ng-model不喜欢表达式(我首先尝试了ng-model="{{myVariableWhichContainsDesiredNgModelString}}"),因此我在这篇文章中结束了:AngularJS-Createadirectivethatusesng-model。虽然接受的答案似乎适用于简单设置,但我从接受的答案中编辑了plunker以测试它是否也适用于嵌套指令

javascript - Angular Directive(指令) mouseenter/mouseleave 工作但在 mouseleave 后不设置为初始状态

我有一个指令在模板上显示学生信息列表,然后在鼠标输入时显示其他学生信息。我希望能够返回到mouseleave的初始状态。尝试了所有资源,但运气不佳。html-这是我注入(inject)指令的地方html指令模板Name:{{student.name.first}}{{student.name.last}}Bio:{{student.Bio}}Skills:{{skill.title}}指令app.directive('portfolioView',function(){return{restrict:'E',scope:{student:"="},templateUrl:'/html-

javascript - angular-leaflet-directive 自定义消息 html,在标记弹出窗口中带有 Angular Directive(指令)。如何?

我想将带有$scope事件处理程序的自定义html标记插入传单标记的消息属性。例如:App.controller('testController',['$scope',"leafletEvents",'$compile','leafletMarkersHelpers',function($scope,leafletEvents,$compile,leafletMarkersHelpers){angular.extend($scope,{currentLocation:{lat:20,lng:20,zoom:20},markers:{},defaults:{scrollWheelZoom

javascript - 如何使用 angularJS 制作虚拟卷轴?

我试图制定一个指令,我可以做一个虚拟滚动,所以当用户滚动表格时,表格删除“旧”View并添加"new"View,有点像收集重复,但我已经一直失败,我想我不明白它背后的数学原理,有人可以帮助我吗?这是我的指令代码:BaseModule.directive('myScroll',function(){return{restrict:"A",scope:{rows:"=",headers:"="},link:function(scope,el){varscrollTop=0;varscrollLeft=0;angular.element(el).on('scroll',function(){

javascript - 错误 : Expression 'undefined' used with directive is non-assignable

在这里摆弄http://jsfiddle.net/prantikv/dJty6/36/我有这样的json数据$scope.info={"company1":"this","company2":"is","company3":"sparta"}我正在使用ng-repeat打印所有数据,我想监控字段的变化。我有一个像这样的monitorChange指令:.directive('monitorChange',function(){return{restrict:'A',scope:{changedFlag:'='},link:function(scope,element,attrs){var

javascript - ngrepeat 中的 Angularjs 动态指令

看例子:$scope.fields=[{name:'Email',dir:"abc"},{name:'List',dir:"ddd"}];app.directive('abc',function(){});app.directive('ddd',function(){});我如何编写代码,p.dir将动态转换为指令?我的例子:hhttp://jsbin.com/vejib/1/edit 最佳答案 试试这个指令:app.directive('dynamicDirective',function($compile){return{res

javascript - 如何将 jQuery 代码转换为可用的 AngularJS 代码

我是AngularJS的新手,想为登录页面创建类似于您在单击“忘记密码”链接时在此处找到的功能:http://bootsnipp.com/snippets/featured/login-amp-password-reminder#comments是否最好使用指令,因为这是行为的,而不是Controller?我已经尝试过为它创建一个Controller,但是当我搜索有关该主题的帮助时,我发现为此使用Controller可能不是可行的方法。这是我最近一次失败的试验(点击链接时没有任何反应):在js文件中的Controller端:angular.module('mean.users').co

javascript - 将数据传递给嵌入的元素

我想创建一个指令来组织按日期分组的显示数据。我还希望能够指定一个指令来显示各个行。在一个完美的世界中,它看起来像这样(但又漂亮又漂亮)Friday,Oct28[somedirectivehtml][somedirectivehtml][somedirectivehtml]Saturday,Oct29[somedirectivehtml]Sunday,Oct30[somedirectivehtml][somedirectivehtml]...这显然行不通,所以如果您有更好的方法请告诉我,但我希望能够按照这些思路做一些事情:app.directive('dateOrganized',[fu

javascript - Vue.js 2,从指令更改数据

使用单文件组件,如何从指令更改数据属性?例如,我有...exportdefault{name:'app',data:function(){return{is_loading:true}},directives:{do_something:{bind:function(el,binding,vnode){//Changetheis_loadingproperty}}}}起初我以为我可以做this.is_loading=false但this是undefined。 最佳答案 要在指令中引用this,您可以简单地使用vnode.contex

javascript - Angular : src attribute bug in Iframe directive

我在尝试实现Iframe指令时遇到问题。就我而言:模板:指令:angular.module('project.directives',[]).directive('externalIframe',['$rootScope',function($rootScope){return{restrict:'C',replace:true,transclude:true,scope:{src:'@iframeSrc',//thesrcusesthedata-bindingfromtheparentscope},template:'',link:function(scope,elem,attrs)