本文整理汇总了TypeScript中app.directive函数的典型用法代码示例。如果您正苦于以下问题:TypeScript directive函数的具体用法?TypeScript directive怎么用?TypeScript directive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了directive函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
// Created by baihuibo on 16/3/30.
import app from "app";
/**
* @examples
* <iframe frame-src="{{T.src}}"></iframe>
*
* class TestCtrl{
* public src:string = '';
*
* constructor(){
* this.src = 'http://host/to/path/to/file'
* }
* }
*/
app.directive('frameSrc', function () {
return function (scope, iframe, attr) {
if (iframe.is('iframe')) {
attr.$observe('iframeSrc', function (val) {
iframe.attr('src', val || 'about:blank');
});
} else {
console.warn('not iframe tag');
}
}
});
开发者ID:baihuibo,项目名称:idsp-base-web-seed,代码行数:26,代码来源:frame-src.ts
示例2: function
app.directive('remoteValid', function ($log) {
var defaults = {
method: 'get',
check: null,
params: {},
invokeParam: {}
};
var name = "remoteValid";
return {
restrict: 'A',
require: '?ngModel',
scope: {option: '=remoteValid'},
link: function (scope:any, el, attr, ctrl) {
if (!ctrl)return;
var option:RemoteValidOption = _.defaults(scope.option || {}, defaults);
function validData(newVal) {
option.params.value = newVal;
option.resource[option.method](
option.invokeParam,
option.params,
function (data) {
var pass;
if (option.check && _.isFunction(option.check)) {
pass = option.check(data);
} else {
pass = !!data.result;
}
ctrl.$setValidity(name, pass);
}, function () {
ctrl.$setValidity(name, false);
});
return newVal;
}
el.on('paste', false);
ctrl.$parsers.push(validData);
scope.$watch(attr.ngModel, function (newVal, oldVal) {
if (!newVal || newVal != oldVal) {
ctrl.$setValidity(name, true);
}
});
}
}
});
开发者ID:baihuibo,项目名称:idsp-base-web-seed,代码行数:48,代码来源:remoteValid.ts
示例3: function
app.directive("remotePaging", function () {
/**
* @prop total 数据总数
* @prop totalPage 总页数
* @prop current 当前页数
* @prop limit 限制数据大小
* @prop data 当前页数据
*/
interface PagingResult {
total:number
totalPage:number
current:number
limit:number
data:any[]
}
var defaults = {
method: 'get',
limit: 10,
total: 0,
resultList: [],
limitList: [10, 20, 30, 40, 50],
pagingSize: 5,
params: null,
hideDesc: false,
invokeParam: "paging",
reloadAll: false
};
return {
templateUrl: 'scripts/__base/directives/paging/paging.html',
scope: {
option: "="//配置对象 {Paging}
},
link: function (scope:any, el, attr) {
var option:PagingOption = scope.option = _.defaults(scope.option || {}, defaults);
var pagingSize = option.pagingSize;
scope.$watch('option.pagingSize', function (newVal, oldVal) {
if (oldVal && newVal != oldVal) {
pagingSize = newVal;
option.goToPage('first', true);
}
});
var limit = option.limit;
scope.$watch('option.limit', function (newVal, oldVal) {
if (oldVal && newVal != oldVal) {
limit = newVal;
option.goToPage('first', true);
}
});
var loading;
//读取对应页面的数据
scope.goToPage = function (page, reload) {//to page data
if (page < 0 || (option.totalPage && page >= option.totalPage) || (page == option.currentPage && !reload)) {
return;
}
var data = {
current: page,
limit: limit,
method: option.method,
reload: option.reloadAll || !!reload,
total: option.total,
params: angular.toJson(option.params || {})
};
loading = true;
option.resource[option.method](option.invokeParam, data,
function (result:PagingResult) {
option.currentPage = result.current;
option.total = result.total;
option.totalPage = result.totalPage;
option.resultList = _.map(result.data || [], function (item) {
return new option.resource(item);
});
initPageList(option.totalPage , option.currentPage);
loading = false;
}, function () {
loading = false;
});
};
//监听是否有resource资源准备就绪
scope.$watch('option.resource', function () {
option.resource && scope.goToPage(0, true);
});
//刷新数据
option.goToPage = function (page, reload) {
if (!option.resource || loading) return;//不要重复加载,跳出方法
switch (page) {
case "first" :
scope.goToPage(0, reload);
break;
case "last" :
scope.goToPage(option.totalPage - 1, reload);
break;
default:
scope.goToPage(option.currentPage, reload);
//.........这里部分代码省略.........
开发者ID:cetrinw,项目名称:reptile,代码行数:101,代码来源:paging.ts
示例4: function
// Created by baihuibo on 16/3/29.
import app from "app";
app.directive("helloWord", function () {
return {
link: function (scope, el, attr) {
el.text('hello seed');
}
}
});
开发者ID:baihuibo,项目名称:idsp-base-web-seed,代码行数:10,代码来源:HelloWord.ts
注:本文中的app.directive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论