I dont know if its a valid question but as long as i inject ngRoute into my app my $scope is undefined.
the app without ng-Route looks like this
angular.module('DummyApp', [])
.controller('DummyCtrl', ['$scope', function ($scope) {
$scope.name = "World";
}]);
the test case like this
describe( 'Dummy Controller', function(){
var scope, http, DummyCtrl;
beforeEach(module('DummyApp'));
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
DummyCtrl = $controller('DummyCtrl', {
$scope: scope
});
}));
it('should contain the word world', function(){
expect(scope.name).toEqual("World");
});
});
passing without any error
but if i inject the ngRoute to my app
angular.module('DummyApp', ['ngRoute'])
.controller('DummyCtrl', ['$scope', function ($scope) {
$scope.name = "World";
}]);
TypeError: 'undefined' is not an object (evaluating 'scope.name')
I also tried to configure the $routeProvider see below but i just don't know how to write my test if the ngRoute is injected
angular.module('DummyApp', ['ngRoute']).app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/smth', {
templateUrl: 'smth.html',
controller: 'testController'
});
}])
.controller('DummyCtrl', ['$scope', function ($scope) {
$scope.name = "World";
}]);