角度控制器代码:
n="Wed, 26 May 2017 14:00:00 +0800"
m=n.to_datetime
m.strftime("%Y-%m-%d %H:%M:%S %z")
output: "2017-05-26 14:00:00 +0800"
角度模块代码:
(function ()
{
myApp.controller("LoginController", function ($scope, $http, $location, $window) {
$scope.Emp = {};
console.log("cont");
$scope.Submit = function (Emp) {
console.log("inside", $scope.Emp);
$http({
method: "POST",
url: '#/Test/Login',
data: $scope.Emp,
})
.then(function successCallback(response) {
console.log("response", response.data);
//$window.location.href = '/Home/Display';
if (response.data == "CORRECT UserName and Password") {
console.log("if condition")
$window.location.href = '/Test/Display';
}
else if (response.data == "INCORRECT UserName") {
alert("INCORRECT UserName or Password");
}
})
}
$scope.Register = function () {
$window.location.href = '/Test/Register';
}
});
})(angular.module('myApp'));
答案 0 :(得分:0)
您只是在$LogProvider
之后声明了没有在配置中注入$scope
。声明和注射也必须相同且准确。
应该是这样的:
app.config('$StateProvider', '$UrlRouteProvider', '$scope', '$LogProvider', '$http', '$location', '$window',
function ($StateProvider, $UrlRouteProvider, $scope, $LogProvider, $http, $location, $window)
{
$UrlRouteProvider.otherwise("/Login");
$StateProvider
.state('Login'),{
url:'/Login',
views:{
'@':{
templateUrl: "/Views/Home/Login.cshtml",
controller: 'LoginController'
}
}
}})
如果您需要,#
检查中还有url: '#/Test/Login',
。
此外,根据您的相关代码,似乎您在配置中不需要这些依赖项。在您的代码中,我没有看到使用$scope, $LogProvider, $http, $location, $window..