本文整理汇总了TypeScript中angular.toJson函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toJson函数的具体用法?TypeScript toJson怎么用?TypeScript toJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toJson函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('calls back with tribes on success', async function () {
const expectedTribes = [{
_id: 'one'
}, {
_id: 'two'
}];
const getSpy = spyOn(axios, 'get')
.and.returnValue(Bluebird.resolve({data: expectedTribes}));
const resultTribes = await Coupling.getTribes();
expect(getSpy).toHaveBeenCalledWith('/api/tribes');
expect(angular.toJson(resultTribes)).toEqual(angular.toJson(expectedTribes));
});
示例2: set
set(title, text, severity, timeout) {
var newAlert = {
title: title || '',
text: text || '',
severity: severity || 'info',
};
var newAlertJson = angular.toJson(newAlert);
// remove same alert if it already exists
_.remove(this.list, function(value) {
return angular.toJson(value) === newAlertJson;
});
this.list.push(newAlert);
if (timeout > 0) {
this.$timeout(() => {
this.list = _.without(this.list, newAlert);
}, timeout);
}
if (!this.$rootScope.$$phase) {
this.$rootScope.$digest();
}
return(newAlert);
}
示例3: constructor
constructor (
private $mdDialog: ng.material.IDialogService,
private $scope: any,
private $rootScope: ng.IRootScopeService,
private $state: StateService,
private ApiService,
private NotificationService,
private resolvedEvents,
private $timeout
) {
'ngInject';
this.api = JSON.parse(angular.toJson(_.cloneDeep(this.$scope.$parent.apiCtrl.api)));
this.events = resolvedEvents.data;
this.eventsSelected = [];
this.eventsTimeline = [];
this.eventsToCompare = [];
this.eventSelected = {};
this.diffMode = false;
this.eventToCompareRequired = false;
this.eventTypes = "PUBLISH_API";
this.cleanAPI(this.api);
this.init();
this.initTimeline(this.events);
}
示例4: wechatPay
private wechatPay(prepayid){
let appid="wxd585ab5057bdc266";
let noncestr = this.commonUtil.randomString(32);
let timestamp = Math.round(new Date().getTime()/1000).toString();//时间戳 单位需要为秒(10位数字)
let temp="appid="+appid+"&partnerid=1505050301&prepayid="+prepayid+"&package=Sign=WXPay&noncestr="+noncestr+"×tamp="+timestamp+"";
let signTemp = temp+"&key=zjlgwlapipasswordaaaaaaaaaaaaaaa" //商户平台设置的密钥key
alert("noncestr:"+noncestr.length)
let sign = Md5.hashStr(signTemp).toString().toUpperCase() //MD5签名方式
let params = {
appid : appid,
partnerid: '1505050301',
prepayid: prepayid,
package:'Sign=WXPay',
noncestr: noncestr,
timestamp: timestamp,
sign: sign,
};
console.log(params)
alert(angular.toJson(params))
this.wechat.sendPaymentRequest(params).then((result)=>{
//支付成功
alert(result)
},(error)=>{
//支付失败
alert(error)
})
}
示例5: alert
.then(res=>{
alert(angular.toJson(res))
if(res.retcode == AppConfig.responseCode.successCode){
let resultData = this.commonUtil.parseData(res.retObj)
this.wechatPay(resultData.prepay_id);
}
})
示例6: set
set(title, text, severity, timeout) {
if (_.isObject(text)) {
console.log('alert error', text);
if (text.statusText) {
text = `HTTP Error (${text.status}) ${text.statusText}`;
}
}
var newAlert = {
title: title || '',
text: text || '',
severity: severity || 'info',
};
var newAlertJson = angular.toJson(newAlert);
// remove same alert if it already exists
_.remove(this.list, function(value) {
return angular.toJson(value) === newAlertJson;
});
this.list.push(newAlert);
if (timeout > 0) {
this.$timeout(() => {
this.list = _.without(this.list, newAlert);
}, timeout);
}
if (!this.$rootScope.$$phase) {
this.$rootScope.$digest();
}
return(newAlert);
}
示例7: getQueryHeader
getQueryHeader(searchType, timeFrom, timeTo) {
return angular.toJson({
search_type: searchType,
"ignore_unavailable": true,
index: this.indexPattern.getIndexList(timeFrom, timeTo),
});
}
示例8: getTerms
getTerms(queryDef) {
const range = this.timeSrv.timeRange();
const searchType = this.esVersion >= 5 ? 'query_then_fetch' : 'count';
const header = this.getQueryHeader(searchType, range.from, range.to);
let esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef));
esQuery = esQuery.replace(/\$timeFrom/g, range.from.valueOf());
esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf());
esQuery = header + '\n' + esQuery + '\n';
const url = this.getMultiSearchUrl();
return this.post(url, esQuery).then(res => {
if (!res.responses[0].aggregations) {
return [];
}
const buckets = res.responses[0].aggregations['1'].buckets;
return _.map(buckets, bucket => {
return {
text: bucket.key_as_string || bucket.key,
value: bucket.key,
};
});
});
}
示例9: hasChanges
hasChanges() {
let current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone());
let original = this.cleanDashboardFromIgnoredChanges(this.original);
var currentTimepicker = _.find(current.nav, { type: 'timepicker' });
var originalTimepicker = _.find(original.nav, { type: 'timepicker' });
if (currentTimepicker && originalTimepicker) {
currentTimepicker.now = originalTimepicker.now;
}
var currentJson = angular.toJson(current, true);
var originalJson = angular.toJson(original, true);
return currentJson !== originalJson;
}
示例10: function
return function(arr) {
if (_.isObject(arr) && !_.isArray(arr)) {
return angular.toJson(arr);
} else {
return _.isNull(arr) ? null : arr.toString();
}
};