2017-05-09 63 views
0

問題是,我無法加載JavaScript文件(如@ angular/core,@ angular/form) 我在liferay中添加了node_modules結構,但無法解決如何導入文件的問題。 因此,任何人都可以提供解決方案或步驟積分角2與liferay 6.2整合角2與liferay 6.2

回答

0

問題不在於只加載node_modules。

對於負載角2的Liferay 6.2

你portal_normal.vm [的index.html]應該包含這樣&加載庫。

<!DOCTYPE html> 
<html> 
    <head> 
    <script>document.write('<base href="' + document.location + '" />');</script> 
    <title>NgModule Deluxe</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <script src="https://npmcdn.com/core-js/client/shim.min.js"></script> 
    <script src="https://npmcdn.com/[email protected]?main=browser"></script> 
    <script src="https://npmcdn.com/[email protected]"></script> 
    <script src="https://npmcdn.com/[email protected]/dist/system.src.js"></script> 
    <script src="systemjs.config.js"></script> 
    <script> 
     System.import('main.ts').catch(function(err){ console.error(err); }); 
    </script> 
    </head> 

    <body> 
    <app-root>Loading...</app-root> 
    </body> 
</html> 

下一步是你的main.ts加載,它引導你的根模塊。

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import { AppModule } from './app/app.module'; 

platformBrowserDynamic().bootstrapModule(AppModule); 

那麼你的AppModule被裝起來,這將做要緊,你需要的任務運動員誰做了必要的transpilation。

例如:Maven的+ NPM

樣品POM

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.5.RELEASE</version> 
</parent> 

<packaging>war</packaging> 


<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>exec-npm-install</id> 
        <phase>generate-sources</phase> 
        <configuration> 
         <workingDirectory>${project.basedir}/src/main/resources</workingDirectory> 
         <executable>npm</executable> 
         <arguments> 
          <argument>install</argument> 
         </arguments> 
        </configuration> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>exec-npm-run-tsc</id> 
        <phase>generate-sources</phase> 
        <configuration> 
         <workingDirectory>${project.basedir}/src/main/resources</workingDirectory> 
         <executable>npm</executable> 
         <arguments> 
          <argument>run</argument> 
          <argument>tsc</argument> 
         </arguments> 
        </configuration> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

而這正是所有的文件將被保留。

src/main/resources 
       /app   - .ts and converted .js 
       /css 
       /images 
       /js   - systemjs.config.js is also placed here 
       /node_modules - generated by npm install and will include in war 
       /typings 
       package.json 
       tsconfig.json 
       typings.json