本文整理匯總了TypeScript中ng2-json-editor.JsonStoreService.addIn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript JsonStoreService.addIn方法的具體用法?TypeScript JsonStoreService.addIn怎麽用?TypeScript JsonStoreService.addIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ng2-json-editor.JsonStoreService
的用法示例。
在下文中一共展示了JsonStoreService.addIn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
splitResult.splits.forEach(split => {
// handle array insert
let relativePath = split.path;
let insertLast = relativePath.findIndex(el => el === '-');
if (insertLast > -1) {
let valueToInsert;
let sliceIndex = insertLast + 1;
let insertPath = relativePath.slice(0, sliceIndex);
if (sliceIndex < relativePath.length) {
let afterInsertPath = relativePath.slice(sliceIndex);
let stub = {};
stub[afterInsertPath[afterInsertPath.length - 1]] = split.value;
for (let i = afterInsertPath.length - 2; i >= 0; i--) {
let temp = { [afterInsertPath[i]]: stub };
stub = temp;
}
valueToInsert = stub;
} else {
valueToInsert = split.value;
}
let fullInsertPath = referencePath.concat(insertPath);
jsonStore.addIn(fullInsertPath, valueToInsert);
} else {
let toPath = referencePath.concat(split.path);
jsonStore.setIn(toPath, split.value);
}
});
示例2:
.subscribe(uploadedPath => {
this.jsonStoreService.addIn(['documents', '-'], { url: uploadedPath, key: file.name });
this.toastrService.clear(infoToast.toastId);
this.toastrService.success(`File uploaded`, 'Success');
}, error => {