Skip to content

Router to render react routes in a Angular application

License

Notifications You must be signed in to change notification settings

angular-libs/ng-react-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ng-react-router Build Status

Router to render react routes in a Angular application

install

npm i ng-react-router

example

react-page.js

const ReactPage = ()=> `<p>this is react page</p>`;

export default const routes= [{
  path:'react-page',
  component:ReactPage
}]

angular-app.js

import { provider } from 'ng-react-router'
angular.module('react-module', [
  uiRouter , 'ng-react-router'
])
.config(($stateProvider, $urlRouterProvider) => {
  "ngInject";
  const options={
      state:'react-module',
      basePath:'/react-app',
      routeResolver:(path)=> {
        // path will be react-page                        
        return System.import('./'+path).then((module=>module.default)); 
      },
      templateProvider:(err,uiView)=>{
        if(err){
            return `Page not found`
        }
        return `
            <h2>React Page</h2>
            ${uiView}
        `  
      }
    };
  provider(options,$stateProvider);
})

License

MIT License

About

Router to render react routes in a Angular application

Resources

License

Stars

Watchers

Forks

Packages

No packages published