The parts of codes are mentioned below. Everything works fine in chrome, 
but while trying to unit test using karma, I am unable to access the scope 
variables in the external controller file. Please help as i am stuck 
without any solutions.

https://github.com/tnajdek/angular-requirejs-seed/

Below is the code for the unit test case

define([
'angular',
'angularMocks',
'app'
], function(angular, mocks, app) {

describe('MyCtrl2', function(){
var MyCtrl2, $scope = null;

beforeEach(function() {
mocks.module('myApp.controllers');
mocks.inject(function($rootScope, $controller, $injector) {
$scope = $rootScope.$new();
MyCtrl2 = $controller('MyCtrl2', {
$scope: $scope
 });
});
});

});



CONTROLLERS file:

define(['angular', 'services/services'], function (angular) {

return angular.module('myApp.controllers')


.controller('MyCtrl2', ['$scope', '$injector', function ($scope, $injector) 
{
$scope.normalValue = 'beforeOutsideControllerFile'; //THIS WORKS;
require(['controllers/myctrl2'], function(myctrl2) {
$injector.invoke(myctrl2, this, {'$scope': $scope});
});
}])


});



Separate controller file:

define([], function() {
return ['$scope', '$http', function($scope, $http) {
$scope.welcomeMessage = 'hey'; //THIS DOES NOT WORK IN UNIT TESTING;
$scope.$apply();
}];
});

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to