由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Angular ng-include not working
相关主题
Angularjs ng-click redirect not working as expected如何让angular网页同时支持IE9和IE11 ?
有台电脑的IE11无法正常显示angular页面java script哪个framework比较好用?
node.js, express, sails, angularjs在一起做project,折磨人啊现在来看backbone和angular哪个更有前途呢?
express.js的作者弃node转投goAngularJS 怎么样?
初学JavaScript,问一个小问题angular是否淘汰jquery了














Code Country Population
{{country.code}} {{country.name}} {{country.population}}


w*s
发帖数: 7227
3
index2.html which is not working,
i don't see this line
console.log("returning Json data");
triggered in the server











w*s
发帖数: 7227
4
server side
app.get('/testJson', function(req, res)
{
console.log("returning Json data");
res.json( [{code : "US", name : "United States", population : "11223344"
}] );
});
/*
w*s
发帖数: 7227
5
上美图,求帮助,谢谢各位大牛!
w*s
发帖数: 7227
6
statusApp.js
var app = angular.module('HelloModule', []);
app.controller('HelloCtrl', function($scope, HelloService) {
//$scope.countries = [{code : "US", name : "United States",
population : "11223344"}];
HelloService.getJson().then(function(result) {
$scope.countries = result;
}, function(error) {
alert("Error");
} );
});
app.factory('HelloService', function($http, $q) {
return {
getJson: function() {
var deferred = $q.defer();
var browserProtocol = 'http';
var port = ':1234';
var address = 'localhost';
var server = browserProtocol + '://' + address;
var url = server + port + '/testJson';
//$http.get('http://localhost:7778/testJson').success(function(data) {
$http.get(url).success(function(data) {
deferred.resolve(data);
}).error(function(){
deferred.reject();
});
return deferred.promise;
}
}
});
n*****t
发帖数: 22014
7
没有 ng-controller 就不会执行里面的代码

【在 w*s 的大作中提到】
: index2.html which is not working,
: i don't see this line
: console.log("returning Json data");
: triggered in the server
:
:
:
:
:
:

n*****t
发帖数: 22014
8
抱歉没看仔细,你这里涉及多个 ngApp,而且 nested 是不允许的

【在 n*****t 的大作中提到】
: 没有 ng-controller 就不会执行里面的代码
w*s
发帖数: 7227
9
什么,这是最简单的情形,怎么可能不允许。
别的地方让我把status.html改成











Code Country Population
{{country.code}} {{country.name}} {{country.population}}

And ng-include works like this :



但尼玛的还不行

【在 n*****t 的大作中提到】
: 抱歉没看仔细,你这里涉及多个 ngApp,而且 nested 是不允许的
w*s
发帖数: 7227
相关主题