本文整理汇总了TypeScript中angular.isDefined函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isDefined函数的具体用法?TypeScript isDefined怎么用?TypeScript isDefined使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isDefined函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
link: function (scope: any, elem: any, attrs: any) {
var scrollSelector = attrs.scrollSelector;
var offset = angular.isDefined(attrs.offset) ? parseInt(attrs.offset) : 0;
var scrollContainerElem = angular.isDefined(scrollSelector) ? angular.element(scrollSelector) : $win;
var currLeftPos = elem[0].offsetLeft;
scrollContainerElem.on('scroll', function (e) {
stickIt();
});
function stickIt() {
var scrollAmount = scrollContainerElem.scrollTop();
elem.css('top', (scrollAmount + offset) + 'px');
elem.css('position', 'absolute');
elem.css('padding-left', '15px')
}
elem.bind("stickIt", function () {
stickIt();
});
scope.$on('$destroy', function () {
elem.unbind("stickIt");
});
}
示例2: return
return (str: string, regExStr: string, replaceValue: string) => {
if (!isDefined(regExStr)) {
$log.debug(`Did not supply regex string for 'replace' filter.`);
return str;
} else if (!isDefined(replaceValue)) {
$log.debug(`Did not supply replacement value for 'replace' filter.`);
return str;
} else {
return str.replace(new RegExp(regExStr, 'g'), replaceValue);
}
};
示例3:
tableOptionInitializerPromise.then((file:any) => {
var serviceName = $scope.tableOption.initializeServiceName;
if(angular.isDefined(serviceName)) {
var svc = $injector.get(serviceName);
if (angular.isDefined(svc) && angular.isFunction(svc.initializeCreateFeed)) {
var createFeedModel = FeedService.createFeedModel;
svc.initializeCreateFeed($scope.tableOption, stepperController, createFeedModel);
}
}
});
示例4: update
link: ($scope: any, element: any, attrs: any)=> {
$scope.truncatedFormat = angular.isDefined($scope.truncatedFormat) ? $scope.truncatedFormat : false;
$scope.addAgoSuffix = angular.isDefined($scope.addAgoSuffix) ? $scope.addAgoSuffix : false;
$scope.time = $scope.startTime;
$scope.previousDisplayStr = '';
$scope.$watch('startTime', (newVal: any, oldVal: any)=> {
$scope.time = $scope.startTime;
format();
})
format();
var seconds = 0;
var minutes = 0;
var hours = 0;
var days = 0;
var months = 0;
var years = 0;
if ($scope.refreshTime == undefined) {
$scope.refreshTime = 1000;
}
function update() {
$scope.time += $scope.refreshTime;
//format it
format();
}
function format() {
var ms = $scope.time;
var displayStr = DateTimeUtils($filter('translate')).formatMillisAsText(ms,$scope.truncatedFormat,false);
if($scope.addAgoSuffix) {
displayStr += " ago";
}
if ($scope.previousDisplayStr == '' || $scope.previousDisplayStr != displayStr) {
element.html(displayStr);
element.attr('title', displayStr);
}
$scope.previousDisplayStr = displayStr;
}
var interval = $interval(update, $scope.refreshTime);
var clearInterval = ()=> {
$interval.cancel(interval);
interval = null;
}
$scope.$on('$destroy', ()=> {
clearInterval()
});
}
示例5: check
/**
*
* @param permissions array of permissions needed (only 1 is needed)
* @param entity optional entity
*/
function check(permissions: any, entity: any, entityType: any) {
if (angular.isDefined(entity) && angular.isDefined(entityType)) {
validate(accessControlService.hasEntityAccess(permissions, entity,entityType));
}
else {
accessControlService.getUserAllowedActions(accessControlService.ACCESS_MODULES.SERVICES, true)
.then(function (actionSet: any) {
var valid = accessControlService.hasAnyAction(permissions, actionSet.actions);
validate(valid);
}, true);
}
}
示例6: text
this.text = function text(textId: string, projectId?: string): string {
if (angular.isDefined(projectId)) {
return this.project(projectId) + textId;
} else {
return this.project() + textId;
}
};
示例7: setupField
/**
* Sets up and configures properties for a dialog field
* @memberof DialogDataService
* @function setupField
* @param data {any} This is a object that is all the information for a particular dialog field
*
**/
public setupField(data: any) {
let field = _.cloneDeep(data);
const dropDownValues = [];
field.fieldValidation = null;
field.fieldBeingRefreshed = (angular.isDefined(field.fieldBeingRefreshed) ? field.fieldBeingRefreshed : false);
field.errorMessage = '';
if (field.type === 'DialogFieldDropDownList') {
for (let option of field.values) {
if (option[0] === String(field.default_value)) {
field.selected = option;
}
if (field.data_type === 'integer') {
dropDownValues.push([parseInt(option[0], 10), option[1]]);
} else {
dropDownValues.push(option);
}
}
field.values = dropDownValues;
field.values = this.updateFieldSortOrder(field);
}
field.default_value = this.setDefaultValue(field);
return field;
}
示例8: function
vm.openColumnsSortPanel = function (value) {
if (angular.isDefined(value))
vm.columnSortPanelOpened = value;
else {
vm.columnSortPanelOpened = !vm.columnSortPanelOpened;
}
}
示例9: setDefaultValue
/**
*
* This method sets default value for a dialog field
* @memberof DialogDataService
* @function setDefaultValue
* @param data {any} This is a object that is all the information for a particular dialog field
*
**/
private setDefaultValue(data): any {
let defaultValue: any = '';
const firstOption = 0; // these are meant to help make code more readable
const fieldValue = 0;
if (_.isObject(data.values)) {
if (angular.isDefined(data.default_value) && data.default_value !== null) {
defaultValue = data.default_value;
} else {
defaultValue = data.values[firstOption][fieldValue];
}
} else {
if (data.type === 'DialogFieldDateControl' || data.type === 'DialogFieldDateTimeControl') {
defaultValue = new Date(data.values);
} else {
defaultValue = data.values;
}
}
if (data.default_value) {
defaultValue = data.default_value;
}
if (data.data_type === 'integer') {
defaultValue = parseInt(data.default_value, 10);
}
return defaultValue;
}
示例10: project
this.project = function project(projectId?: string, projectType: string = 'sfchecks'): string {
if (angular.isDefined(projectId)) {
return '/app/' + projectType + '/' + projectId + '#!/';
} else {
return '#!/';
}
};