w*s 发帖数: 7227 | 1 1./mypath/status.html works fine, it sends "testJson" to node server, then
displays data to the webpage
2. now i have /mypath/index2.html, which ng-include status.html, it won't
trigger "testJson" in the server code
i'll put more details |
w*s 发帖数: 7227 | 2 status.html
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 | |
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 | |
|
|
w*s 发帖数: 7227 | 11 这angular太他妈的折腾人了,到现在我脑袋还是一团浆糊 |
n*****t 发帖数: 22014 | |
w*s 发帖数: 7227 | 13 我只有一个ng-app
var app = angular.module('HelloModule', []);
【在 n*****t 的大作中提到】 : 不知道你怎么折腾出来的,但是ngApp 明确有规定,你可以看看
|
l**********n 发帖数: 8443 | 14 你自己不会debug?
【在 w*s 的大作中提到】 : 我只有一个ng-app : : var app = angular.module('HelloModule', []);
|
w*s 发帖数: 7227 | 15 靠,老子是写c出身的,只会printf, 不比你们年轻人.
【在 l**********n 的大作中提到】 : 你自己不会debug?
|
n*****t 发帖数: 22014 | 16 大哥,index2 里那个也是啊,就是这个启动 angularjs 的
[在 wds (大盘5000不是梦) 的大作中提到:]
:我只有一个ng-app
:<html ng-app="HelloModule">
:........... |
w*s 发帖数: 7227 | 17 喔,反正最后只能index2.html里有,所以只能有一个。
老姜你好像是全能啊,怎么看都像是南翔技校的,:)
【在 n*****t 的大作中提到】 : 大哥,index2 里那个也是啊,就是这个启动 angularjs 的 : [在 wds (大盘5000不是梦) 的大作中提到:] : :我只有一个ng-app : :<html ng-app="HelloModule"> : :...........
|
n*****t 发帖数: 22014 | 18 我蓝翔扫地的,啥都半瓶醋,啥都不咋明白
【在 w*s 的大作中提到】 : 喔,反正最后只能index2.html里有,所以只能有一个。 : 老姜你好像是全能啊,怎么看都像是南翔技校的,:)
|