0
(function () {

    var app = angular.module('foo', ['bar'])
    .config(function ($stateProvider, $urlRouterProvider) {
        $stateProvider
        .state('home', {
            url:'/home/:Id',
            templateUrl: '/foo/template.thml',
            controller: 'bar'
        })

    });

})();

Here is the Index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<body ng-app="steve">

    <div ui-view></div>
</body>
</html>


<script type="text/javascript" src="Scripts/angular.min.js"></script>
<script type="text/javascript" src="Scripts/angular-ui-router.js"></script>
<script type="text/javascript" src="app/user/BarController.js"></script>
<script type="text/javascript" src="app/App.js"></script>

And The bar controller

(function () {

    var app = angular.module('bar', []);
    app.controller('barCTRL', function () {
        this.mark = 'mark test';
    });


})();

I have a controller created in another JS file, and want to pass it through the controller option in the .state config section. Whenever I do i get this error

Any help would be much appreciated. Thank you very much!

1
  • Typo? bar != barCTRL Commented Jan 2, 2015 at 20:27

1 Answer 1

2

Try this:

var app = angular.module('foo', ['bar'])
    .config(function ($stateProvider, $urlRouterProvider) {
        $stateProvider
        .state('home', {
            url:'/home/:Id',
            templateUrl: '/foo/template.thml',
            controller: 'barCTRL'
        })

    });
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.