angular.js - Several problems with webpack packaging projects?
世界只因有你
世界只因有你 2017-05-15 17:05:16
0
1
471

I recently used webpack to package the angular1. folder, can’t the path of templateUrl in my routing configuration be hard-coded directly?

//app.config.js
routing.$inject = ['$stateProvider', '$urlRouterProvider', '$locationProvider'];

export default function routing($stateProvider, $urlRouterProvider, $locationProvider){
    $urlRouterProvider.otherwise('/home');

    $stateProvider
        .state('home', {
            url: '/home',
            templateUrl: 'views/home.html',
            controller: 'HomeController'
        })
};

2. There are many img srcs in the page, but the paths are wrong after packaging?

<img src="../img/ico_why.png"/>

After using

it seems that the path is wrong too ng-src

3. When using a third-party plug-in, it needs to configure the location of a plug-in

, but after packaging, the path is still wrongbasePath

I feel that the webpack packaging path is very unclear, and various errors are reported!

世界只因有你
世界只因有你

reply all(1)
PHPzhong

Why don’t you import the html template and use that template:
https://github.com/hjzheng/an...
Share a piece of code I wrote before:

import template from './dashboard.partial.html';
import DashboardCtrl from './DashboardCtrl';

function router($stateProvider, $urlRouterProvider) {

    $stateProvider
        .state('dashboard', {
            url: '/dashboard',
            template: template,
            label: 'Dashboard',
            icon: 'glyphicon-dashboard',
            controller: DashboardCtrl,
            controllerAs: '$ctrl'
        });

    $urlRouterProvider.otherwise('/dashboard');
}

router.$inject = ['$stateProvider', '$urlRouterProvider'];

export default router;

As for the image path, I haven’t really studied it. Our products mainly use iconfont, so I’m looking for an answer

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template