0

I am trying to implement angularjs with requirejs

Here is my applicaiton.js file which loads initially

var config = {
    baseUrl: '/assets/',
    paths: {
        jquery: 'jquery',
        twitter: 'twitter',
        angular: 'angular',
        angularjs: 'angularjs',       # This is the directory
        app: 'app'
    },
    shim: {
        'twitter/bootstrap': {
            deps: ['jquery']
        },
        'angular': {
            exports: 'angular'
        },
        'app': {
            deps: ['jquery']
        }
    }
}

requirejs.config(config);

requirejs(['jquery', 'twitter/bootstrap', 'angularjs/app', 'app/common']);

Directory structure

Application.js
Angularjs/
    -controllers/
    -directives/
    -Services/
    -app.js

As startup angularjs/app.js will be initiated and my app.js contains

define('app', ['angular'], function(angular) {
    var app = angular.module('app', []);
    return app;
})

require(['app'], function(app) {
    app.controller('FirstController', function($scope) {
        $scope.message = 'hello';
    })
})  

While running getting the exception as

Failed to instantiate module app

Used this as reference link

Prabhakaran
  • 3,900
  • 15
  • 46
  • 113

1 Answers1

0

That's not a healthy way to use RequireJS aside from the fact that does not work. Please refer to my answer regarding using RequireJS with AngularJS: Does it make sense to use Require.js with Angular.js?

Community
  • 1
  • 1
leog
  • 778
  • 10
  • 15