directive

vue实现点击图片放大图片

一个人想着一个人 提交于 2019-12-06 04:14:22
使用vue一个组件vue-directive-image-previewer A Vue.js project for tag img, click img to zoom out to full screen. 安装vue-directive-image-previewer 命令行 npm install vue-directive-image-previewer -D main.js import VueDirectiveImagePreviewer from 'vue-directive-image-previewer' import 'vue-directive-image-previewer/dist/assets/style.css' Vue.use(VueDirectiveImagePreviewer) components <template> <div> <img v-image-preview src="picture-url"/> </div> </template> 点击这里查看效果 来源: CSDN 作者: 心痛蔓延 链接: https://blog.csdn.net/y895315416/article/details/82963396

how to obtain $attr manually in angular

狂风中的少年 提交于 2019-12-06 03:49:27
I want to know how I might manually obtain the attribute from the linkFn call back. e.g. if I want scope, I do, angular.element(element).scope() controller angular.element(element).controller('ngModel') how about for attr. In the parent controller I suppose you could access the attributes object after first assigning it to a scope property in the directive: <div ng-controller="MyCtrl"> <div my-directive attr1="one">see console log</div> </div> app.directive('myDirective', function() { return { link: function(scope, element, attrs) { scope.attrs = attrs }, } }); function MyCtrl($scope, $timeout

AngularJS Masonry for Dynamically changing heights

…衆ロ難τιáo~ 提交于 2019-12-06 03:32:08
问题 I have divs that expand and contract when clicked on. The Masonry library has worked great for initializing the page. The problem I am experiencing is that with the absolute positioning in place from Masonry and the directive below, when divs expand they overlap with the divs below. I need to have the divs below the expanding div move down to deal with the expansion. My sources are: http://masonry.desandro.com/ and https://github.com/passy/angular-masonry/blob/master/src/angular-masonry.js /*

Getter & setter support with ng-model in AngularJs

ぃ、小莉子 提交于 2019-12-05 15:15:45
问题 I am trying to get getter/setter support for ng-model by implementing a directive that will take care of getting and setting the values to/from the view/model. I am almost there, but I end up in infinite $digest loops. The idea is to set ng-model="$someFieldToStoreInTheScope", and then have the getter/setter directive do the updates between that field and the getter/setter functions. I use $watch to update the model using the setter expression when the ngModelController updates the field in

Directive 自定义指令

心已入冬 提交于 2019-12-05 13:52:31
//全局指令 Vue.directive('指令名',{ //el 就是被绑定的DOM元素   bind:function(el){}, //指令绑定到元素上但是元素没有插入到Dom树的时候   inserted:function(el){},//元素插入到DOM树之后 调用   update:function(el){},//当元素更新的时候,调用 可能多次触发。   componentUpdated:function(el){}, //所在组件的元素和子元素签不更新后调用  unbind:function(el){}, //指令函数解绑时调用。 });Vue.directive("指令名",钩子函数对象) //使用Vue.directive("name",{....});<div v-name></div> //私有的自定义指令new Vue({  el:"#app",  methods:{},  filter:{}, //过滤器  directive:{    name:{      bind:function(el){},// 可以对元素样式进行操作      update:function(el){},    }  },}); 钩子函数的参数:   el:绑定的DOM元素,   binding :一个对象,包含绑定指令的信息 name(指令名字) value

Communication between custom directive and component in Angular2

☆樱花仙子☆ 提交于 2019-12-05 10:22:07
I have a template which has textbox, one 'span' tag and one 'div' tag. 'div' tag has 'selectedColor' custom directive. I want to change background color of 'span' and 'div' tags when input value is changed. So finally I want my directive to react on input change and sets background color of 'div' tag. I also want to change 'span' background color on input value change event. Plunker boot.ts import {Component,bind} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; import {FORM_DIRECTIVES} from 'angular2/form'; import {selectedColorDirective} from 'src/directive'; import

Prolog DCG set_prolog_flag double_quotes source code directive location matters; documentation?

痴心易碎 提交于 2019-12-05 09:56:22
I learned the hard way that with SWI-Prolog the location for the Prolog directive set_prolog_flag matters in a source code file. The only documentation I found of value about loading source code files with directives was in Loading Prolog source files A directive is an instruction to the compiler. Directives are used to set (predicate) properties (see section 4.15), set flags (see set_prolog_flag/2) and load files (this section). Directives are terms of the form :- <term>. Is there documentation for SWI-Prolog that covers loading of source code that notes if a directive applies to the entire

ANGULAR 4 Base64 Upload Component

我的未来我决定 提交于 2019-12-05 05:55:47
I am new to Angular. I am using Angular 4. Where there is a requirement to send the base64 Image as one of the model member to the web api. Is there a Angular component or directive for the that would bind the base64 to the said model? Appreciate and Thank you for the help. You can upload image and store it as base64 encoded. In your template add this <div class="image-upload"> <img [src]="imageSrc" style="max-width:300px;max-height:300px"/> <input name="imageUrl" type="file" accept="image/*" (change)="handleInputChange($event)" /> </div> And this will handle your upload mechanism from

The load sequence difference between template and templateUrl in angular directive

北城以北 提交于 2019-12-04 17:59:54
We were facing this issue several days before. At that time, we were introducing Angular into our HTML5 based mobile family photo social application Family Snap . It's maintained by www.uhella.com . During the restructure, I moved the dojo code into directive inline, it works well. The calendar_month_datepicker (dojox.mobile.SpinWheelDatePicker) was successfully injected by dijit to be a huge Div then. After that, I want to separate it into individual html file as template, because html editor will understand my html code better. So I modify the code as following: Familysnap/directive

Format currency input in angular 2

[亡魂溺海] 提交于 2019-12-04 17:46:41
I want to format input to USD currency as you type. The input will have 2 decimal places and will enter from right to left. Suppose if I type 54.60 it will be entered as $0.05-->$0.54-->$5.46-->$54.60. This PLUNKER exactly does this, but its in angular js. So far my directive looks like: import {Directive, Output, EventEmitter} from '@angular/core'; import {NgControl} from '@angular/forms'; @Directive({ selector: '[formControlName][currency]', host: { '(ngModelChange)': 'onInputChange($event)', '(keydown.backspace)':'onInputChange($event.target.value, true)' } }) export class CurrencyMask {