我面临以下错误
Typerror:无法读取
的属性焦点myapp.controller ('MyController',fucntion ($scope){ document.getElementById("userame").focus(); .... });
示例源代码
document.getElementById()...
请为literal.Text = tableData.ToString();
literal2.Text = tableData2.ToString();
literal3.Text = tableData3.ToString();
答案 0 :(得分:2)
问题已解决。请在下面找到示例代码。
描述( 'myController的',函数(){
var $location,$rootScope,$http,$window,LoginObj,scope;
beforeEach(inject(
function( _$location_,_$rootScope_,_$http_,_$window_,_LoginObj_) {
$location = _$location_;
$rootScope = _$rootScope_;
$http = _$http_;
$window=_$window_;
LoginObj = _LoginObj_;
}));
it('history.go(1) ',function(){
//creating dummy element for html element
var dummyElement = document.createElement('div');
scope = $rootScope.$new();
document.getElementById = jasmine.createSpy('HTML Element').and.returnValue(dummyElement);
var controller = $controller('MyController',{
$scope : $scope
});
//checking the focus of username
spyOn(document.getElementById("username"),'focus');
expect(document.getElementById("username").focus).toBeDefined();