简体   繁体   English

在Sharepoint上设置Angular 2入门教程应用程序

[英]Setting up Angular 2 Getting Started Tutorial App on Sharepoint

I'm trying to load a sample Angular 2 app into a Sharepoint web page. 我正在尝试将示例Angular 2应用程序加载到Sharepoint网页中。 Looking at Angular's Getting Started live Plunker example, 看一下Angular的入门入门实战示例,

There are only 3 files needed: (Ignore the styles.css file.) 只需3个文件:(忽略styles.css文件。)

  • index.html index.html
  • app\\maint.ts app \\ maint.ts
  • app\\app.components.ts app \\ app.components.ts

I added an app folder and these same files onto my webpart but the app doesn't seem to load. 我在我的Webpart中添加了一个应用程序文件夹和这些相同的文件,但该应用程序似乎未加载。 It is not finding the .ts (typescript) file. 找不到.ts(打字稿)文件。

If I view the index.html page, there is an error that is being thrown in the JS: Error: XHR error (404 NOT FOUND) loading https://domain.com/Webparts/app/app.component.ts Error loading https://domain.com/Webparts/app/app.component.ts as "./app.component" from https://domain.com/Webparts/app/main.ts Stack trace: 如果查看index.html页面,则JS中将引发错误:错误:XHR错误(404未找到)加载https://domain.com/Webparts/app/app.component.ts https://domain.com/Webparts/app/app.component.ts从“./app.component” https://domain.com/Webparts/app/main.ts堆栈跟踪:

I have the app folder created and the app.component.ts file underneath that. 我创建了app文件夹,并在其下面创建了app.component.ts文件。 But for some reason, the page can't find that file. 但是由于某种原因,页面无法找到该文件。

Any ideas? 有任何想法吗? I have tried uploading the *.js.map and the *.js files that Typescript generates. 我尝试上传Typescript生成的* .js.map和* .js文件。 But no luck. 但是没有运气。

Looks like I had a path that was wrong. 看来我走错了路。 You just need the .JS files for the application to run if you specify it in the system.config like this. 如果像这样在system.config中指定应用程序,则只需要.JS文件即可运行该应用程序。 (Don't need the TypeScript files on the server.) (不需要服务器上的TypeScript文件。)

System.config({
       packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
      });
System.import('app/main')
     .then(null, console.error.bind(console));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM