directive例子1

(function() {
'use strict';
angular.module('app.widgets')
.directive('confirm', ['confirm2', 'toastr', function(confirm, toastr) {
return {
restrict: "A",
scope: {
ngClick: '&',
confirm: '@',
confirmIf: "=",
confirmOptions: "=",
confirmContext: '=',
confirmIfFalse: "&",
confirmIfFalseMessage: '@'
},
link: function(scope, ele, attrs) {
ele.unbind("click").bind('click', function(event) {
event.preventDefault();
var config = {};
config.content = scope.confirm;
config = angular.extend(config, scope.confirmOptions);
var fn = scope.ngClick;
var context = scope.confirmContext;
if (angular.isUndefined(scope.confirmIf) || scope.confirmIf) {
confirm(config, context)
.ok(function() {
fn();
})
} else {
if (attrs.confirmIfFalse) {
var ifFn = scope.confirmIfFalse;
if (ifFn) {
scope.$apply(ifFn);
}
} else if (scope.confirmIfFalseMessage) {
toastr.warning(scope.confirmIfFalseMessage);
}
}
})
}
};
}])
})();
directive例子1的更多相关文章
- directive例子2
(function() { angular.module('app.widgets') .directive('bsModalPlus', function($window, $sce, $modal ...
- vuejs心法和技法
原文地址:http://www.cnblogs.com/kidsitcn/p/5409994.html 所有的vuejs组件都是被扩展的vue实例: var MyComponent = Vue.ext ...
- AngularJS directive入门例子
这是<AngularJS>这本书里面提供的一个例子: JS代码: var expanderModule=angular.module('expanderModule', []) expan ...
- Directive间的通信
Directive间的通信 源自大漠的<AngularJS>5个实例详解Directive(指令)机制 这个例子主要的难点在于如何在子Expander里面访问外层Accordion的sco ...
- AngularJS之Directive(三)
前言 angular核心部分如下图几大块,最重要的莫过于指令这一部分,本文将重点讲解指令这一部分,后续笔者将通过陆续的学习来叙述其他如:factory.service等,若有叙述错误之处,欢迎各位指正 ...
- Angular自定义指令directive:scope属性
在AngularJS中,除了内置指令如ng-click等,我们还可以自定义指令.自定义指令,是为了扩展DOM元素的功能.代码中,通过指定directive中的restrict属性,来决定这个指令是作为 ...
- angular.js 例子
angular.js是一个前端的MVC框架,12年的时候曾近在一个portal平台的项目中使用过. 下面给出一个angular.js的典型例子,涵盖一些基础的知识点,用以复习备忘: <html ...
- AngularJS中Directive指令系列 - scope属性的使用
文章是转的,我做下补充.原文地址:https://segmentfault.com/a/1190000002773689 每当一个指令被创建的时候,都会有这样一个选择,是继承自己的父作用域(一般是外部 ...
- [译]Exploring Angular 1.3: Binding to Directive Controllers
原文: http://blog.thoughtram.io/angularjs/2015/01/02/exploring-angular-1.3-bindToController.html Angul ...
随机推荐
- 微信小程序页面无法跳转
推荐网址:https://www.jianshu.com/p/e56b55334585 1.无法跳转原因分析 要跳转的路径在app.js里未注册过或路径写错 要跳转的路径是否位于TabBar中 页 ...
- ssh免输入密码登录
ssh免输入密码登录 ubuntu下生成ssh密钥参见. https://confluence.atlassian.com/display/BITBUCKET/Use+the+SSH+prot ...
- 小程序swiper效果高宽设置(微信小程序交流群:604788754)
swiper的宽和高一定要设置在swiper上面.swiper-item默认继承swiper的宽和高.swiper-item容器里面的宽和高没有继承他的父节点宽和高,需要从新设置. 不明白之处,可以咨 ...
- Win10系列:JavaScript综合实例4
实现主页面和分类页面的之后,最后来看一下菜肴页面的实现,这个页面用于详细介绍某项菜肴或主食,如名称.图片和具体做法等.在pages文件夹里面添加一个名为foodDetail的文件夹,并在foodDet ...
- UVa 11636 - Hello World! 二分,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- day4-python基础-运算符
本章节主要说明Python的运算符.举个简单的例子 4 +5 = 9 . 例子中,4 和 5 被称为操作数,"+" 称为运算符. Python语言支持以下类型的运算符: 算术运算符 ...
- 【转载】sprintf()函数 和 printf()函数
sprintf()函数 和 printf()函数 参考:C++ 中的sprintf和snprintf 函数的区别 - CSDN博客 http://blog.csdn.net/youbingchen/ ...
- jenkins部署java项目在本地(三)
(1)新建maven构建的java项目 pom.xml的配置 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...
- Cracking The Coding Interview5.2
//Given a (decimal - e.g. 3.72) number that is passed in as a string, print the binary representatio ...
- 运算类实现 及 GNU Makefile基本结构
1.运算类的实现,代码如下: (1)operator.cpp #include<iostream> #include "operator.h" using names ...