How to include angular2/4 component in JSP page?

后端 未结 4 1134
孤街浪徒
孤街浪徒 2021-02-10 15:12

I want to add angular component into JSP page, what are the possible ways ?

To Describe more :

I have one application dynamic web application in JSP and another

4条回答
  •  臣服心动
    2021-02-10 15:16

    I am able to include my angular component into jsp by bootstrapping it into my application and it runs fine. Below is one way of doing so. Another you can also include the whole component code and bootstrap angular module.

    1. Include below scripts into your index.jsp. here my-app is name of my component
        
        
        
        
        
        
        
        
    
        
         
      
      
      
    
    1. Create app.js file which will bootstrap your angular component.

    app.js

    (function() {
      var MyApp = ng.core.Component({
          selector : 'my-app',
          template : '

    Hello Angular 2!

    ' }).Class({ constructor : function() { } }); document.addEventListener('DOMContentLoaded', function() { ng.platformBrowserDynamic.bootstrap(MyApp); }); })();

    For more information you can read bootstrapping angular application.

提交回复
热议问题