问题
I need some help with this.
I'm supposed to create a plugin for a webpage in angular that communicates with an API written in C# which is already in a .dll. What is the best approach to this?
I already created a data.service.ts
with the following code to get data from the api:
import { Injectable, ValueProvider } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataService {
edge : any = require('edge');
constructor() { }
getData(type: String, method: String) {
var data = this.edge.func({
assemblyFile: 'C:\Program Files\Common Files\Siemens\Automation\Simatic OAM\bin\CC.CommonInterfaces.dll',
typeName: 'CC.CommonInterfaces.${type}',
methodName: '${method}'
});
return data(null, function(error, result) {
if (error) throw error;
console.log(result);
return result;
});
}
}
I want to use the getData method to get the right data frontend with a button click, while also leaving the code as dynamic as possible.
Any advice on this?
来源:https://stackoverflow.com/questions/59664295/creating-a-dataservice-to-communicate-between-c-sharp-api-and-frontend-angular