我正在學習Angular。下面的代碼工作:但是角度進入控制器
.controller('abc', function ($scope, $http)
{
$http.get("/Handlers/Authentication.ashx")
.success(function (data)
{
alert(data);
})
此功能不會:
.controller('abc', function ($scope, $http)
{
$scope.run = function ($scope, $http)
{
$http.get('/Handlers/Authentication.ashx');
// .success(function (data)
//{
// alert(data);
//});
};
}
我知道我應該在這裏使用服務。但學習的目的,我想知道爲什麼它不工作來調用這個函數裏面:
<body ng-app="MainModule">
<div ng-controller="abc">
<div>
<button type="button" class="btn btn-info" ng-click="run();">{{xx}}</button>
感謝您的幫助提前
謝謝,它現在有效 – Yoyosh 2014-09-01 16:15:43