|
<ej-pdfviewer [(serviceUrl)]="service" id="pdfviewer1" [(documentPath)]="docPath" style="width:100%;min-height:600px;display:block" > </ej-pdfviewer> |
|
export class AppComponent {
service: string;
docPath: string;
constructor() {
this.service = 'http://js.syncfusion.com/demos/ejServices/api/PdfViewer';
this.docPath = 'F# Succinctly'; //The document which has been available in our online hosted service.
}
} |
|
public object Load(Dictionary<string, string> jsonResult)
{
//load the multiple document from client side
if (jsonResult.ContainsKey("newFileName"))
{
var name = jsonResult["newFileName"];
var pdfName = name.ToString() + ".pdf";
if (jsonResult.ContainsKey("password"))
{
helper.Load(HttpContext.Current.Server.MapPath("~/App_Data/PdfViewer/" + pdfName), jsonResult["password"]);
}
else
{
helper.Load(HttpContext.Current.Server.MapPath("~/App_Data/PdfViewer/" + pdfName));
}
}
else
{
if (jsonResult.ContainsKey("isInitialLoading"))
{
if (jsonResult.ContainsKey("file"))
{
var name = jsonResult["file"];
helper.Load(name);
}
else
{
helper.Load(HttpContext.Current.Server.MapPath("~/App_Data/PdfViewer/HTTP Succinctly.pdf"));
}
}
}
string output = JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
return output;
} |
I do not have an issue loading when the page initializes, but after action is taken on the page and the report needs to change (url changes), it won't try to get the new report.
So it basically works like this, the api url is something like localhost/api/report/{id:int} so depending on what report is being requested i am want to change the reportUrl to the new report id.
If that is changed in the .ts file to the new id it does not make a new api call to get the new report.
|
protected void Application_Start(object sender, EventArgs e)
{
System.Web.Http.GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}/{action}",
defaults: new { id = RouteParameter.Optional });
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
} |
|
export class AppComponent {
service: string;
constructor() {
this.service = 'http://localhost:57968/api/PdfViewer/10'; //where 10 denotes the id.
}
} |
|
public object Load(int id,Dictionary<string, string> jsonResult)
{
}
//where id will retrieve the value 10 which we have passed in the TS file
|
I think we have a disconnect on what is trying to be accomplished, here is the psuedo code we are using. And the report is displaying fine when the url is set in the onInit(). We just need it to change when we change it in the .ts file.
c# WEbApi:
[Route("{setId}/Load")]
public object Load(int setId, Dictionary<string, string> jsonResult)
{
return this.LoadConcreteReport(setId, jsonResult);
}
.ts
export class ConcreteReviewComponent implements OnInit {
reportUrl: string;
ngOnInit() {
this.reportUrl = "api/concrete/1";
}
changeReport(){
this.reportUrl = "api/concrete/2";
}
}