我想在 Angular 2 应用程序中使用“fast-json-patch”库( https://github.com/Starcounter-Jack/JSON-Patch )。
我试过添加:
'fast-json-patch': 'vendor/fast-json-patch/dist/json-patch-duplex.min.js'
在下的system-config.ts
文件中,map
但导入时不起作用fast-json-patch
我想在 Angular 2 应用程序中使用“fast-json-patch”库( https://github.com/Starcounter-Jack/JSON-Patch )。
我试过添加:
'fast-json-patch': 'vendor/fast-json-patch/dist/json-patch-duplex.min.js'
在下的system-config.ts
文件中,map
但导入时不起作用fast-json-patch
1)安装包
npm install fast-json-patch --save
2)在要使用ist的组件中,导入需要的函数:
import { compare } from 'fast-json-patch';
3)创建补丁比较旧对象和新对象:
const patch = compare(oldObj, modifiedObj);
4) 打印结果:
console.log(patch);
0:{op: "replace", path: "/firmendetails/registergericht", value: "Darmstadt xx"}
1:{op: "remove", path: "/firmendetails/handelsname"}
2:{op: "remove", path: "/firmendetails/firma"}
3:{op: "remove", path: "/firmendetails/rechtsform"}
这是我的system-config.ts
文件的样子:
import * as express from 'express';
import {ng2engine} from 'angular2-universal-preview';
// Angular 2
import {App} from './src/app';
let app = express();
// Express View
app.engine('.ng2.html', ng2engine);
app.set('views', __dirname);
app.set('view engine', 'ng2.html');
// static files
app.use(express.static(__dirname));
app.use('/', (req, res) => {
res.render('index', { App });
});
app.listen(3000, () => {
console.log('Listen on http://localhost:3000');
});
请添加您的代码,以便我看一下?