将JavaScript变量分配给AngularJS范围对象并显示它

将JavaScript变量分配给AngularJS范围对象并显示它,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我是安格拉斯的新手。我试图用JavaScript找到页面的中心点,然后将其绑定到$scope对象。我不完全确定是否正确绑定了JavaScript变量。之后,我尝试预览HTML页面中的值。当我运行代码时,它抛出了一条错误消息 var Page_Center_Width=$(窗口).Width()/2; var Page_Center_Height=$(窗口).Height()/2; var-app=angular.module('myApp',[]); 应用控制器('mainCtrl',函数(

我是安格拉斯的新手。我试图用JavaScript找到页面的中心点,然后将其绑定到$scope对象。我不完全确定是否正确绑定了JavaScript变量。之后,我尝试预览HTML页面中的值。当我运行代码时,它抛出了一条错误消息


var Page_Center_Width=$(窗口).Width()/2;
var Page_Center_Height=$(窗口).Height()/2;
var-app=angular.module('myApp',[]);
应用控制器('mainCtrl',函数($scope,$interval,$window){
$scope.Window\u Width=$Window.Page\u Center\u Width;
$scope.Window\u Height=$Window.Page\u Center\u Height;
});

窗口宽度:{{Window_Width}}
窗高:{{Window_Height}}
var Page\u Center\u Width=$(窗口).Width()/2;
var Page_Center_Height=$(窗口).Height()/2;
var-app=angular.module('myApp',[]);
应用控制器('mainCtrl',函数($scope,$interval,$window){
$scope.Window\u Width=$Window.Page\u Center\u Width;
$scope.Window\u Height=$Window.Page\u Center\u Height;
});

窗口宽度:{{Window_Width}}
窗高:{{Window_Height}}
var Page\u Center\u Width=$(窗口).Width()/2;
var Page_Center_Height=$(窗口).Height()/2;
var-app=angular.module('myApp',[]);
应用控制器('mainCtrl',函数($scope,$interval,$window){
$scope.Window\u Width=$Window.Page\u Center\u Width;
$scope.Window\u Height=$Window.Page\u Center\u Height;
});

窗口宽度:{{Window_Width}}
窗高:{{Window_Height}}

您的代码片段有不同的问题。您将脚本标记放在javascript部分上

var-app=angular.module('myApp',[]);
应用控制器('mainCtrl',函数($scope,$interval,$window){
$scope.Window\u Width=$Window.Page\u Center\u Width;
$scope.Window\u Height=$Window.Page\u Center\u Height;
});

窗口宽度:{{Window_Width}}
窗高:{{Window_Height}}
变量页面中心宽度=3434;
变量页面中心高度=1222;

您的代码片段有不同的问题。您将脚本标记放在javascript部分上

var-app=angular.module('myApp',[]);
应用控制器('mainCtrl',函数($scope,$interval,$window){
$scope.Window\u Width=$Window.Page\u Center\u Width;
$scope.Window\u Height=$Window.Page\u Center\u Height;
});

窗口宽度:{{Window_Width}}
窗高:{{Window_Height}}
变量页面中心宽度=3434;
变量页面中心高度=1222;