Angularjs创建全局变量的动态副本

时间:2014-08-08 17:20:07

标签: javascript jquery angularjs

我正在使用jQuery和Angular创建一个天气应用程序。简单地说,这是我的代码:

(function() {
    forecast = {};
    (function($) {
        forecast.head = "date";
    }(jQuery)();
    var app = angular.module("myApp", []);
    var forecastController = app.controller("forecastController", function() {
        this.data = forecast;
    });
}());

和我的HTML:

<!doctype html>
<html>
<head>
    ...
</head>
<body ng-app="myApp">
    <table ng-controller="forecastController as forecast">
        <thead ng-repeat="item in forecast.data.head">
            <th>{{item}}</th>
        </thead>
        ...
    </table>
</body>
</html>

然而,它没有输出任何东西。 jQuery使用ajax调用来获取天气,这是异步的。如果我不能让它异步,一切都运作良好。但是,我希望它是异步的。

请帮忙!

0 个答案:

没有答案