lundi 27 août 2018

Larave mix - Angularjs fails to load module

I have a problem

I am using Laravel 5.5 and Angular.js 1.7 with laravel-mix, but I am facing problems.

Angular fails to load module. I will post code

**webpack.mix.js**
        mix.scripts([
        'node_modules/angular/angular.js',
        'resources/assets/js/admin.js'
    ], 'public/js/all.js');

admin.js

var app = angular.module("admin", []);

app.controller("AdminController", function($scope) {
    $scope.doSomething = function(){
        console.log('doing something....');
    }
});

I have included angular module in body of template

<body class="hold-transition skin-red sidebar-mini fixed" ng-app="admin">

And mixed js files into footer of blade template

<!-- jQuery 3 -->
<script src=""></script>
<!-- Bootstrap 3.3.7 -->
<script src=""></script>
<!-- AdminLTE App -->
<script src=""></script>

<script src=""></script>
<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. -->
</body>
</html>

Then run

npm run dev

or

npm run watch

but still getting same error

jquery.min.js:2 Uncaught Error: [$injector:modulerr] Failed to instantiate module admin due to:
Error: [$injector:nomod] Module 'admin' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument

This does not make any sense to me!!! If someone can help, shoot! Thank you !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire