角度不渲染视图

时间:2015-02-03 20:51:12

标签: javascript angularjs

我试图通过rdflib.js检索联系人列表。它正确加载并将其保存在范围内的列表中。

它确实识别列表中的项目数,但我无法呈现值,因为$ scope没有更新,似乎我在错误的位置调用$ scope.apply()。这似乎是因为我把它称为有角度的,但我故意在角度上下文(nowOrWhenFetched)之外的函数内调用它,所以对我来说没有意义。有什么帮助吗?

$scope.load = function () {
    //$scope.getContactsList();
    var g = $rdf.graph();
    var f = $rdf.fetcher(g);

    f.nowOrWhenFetched($scope.path + '*',undefined,function(){

    var DC = $rdf.Namespace('http://purl.org/dc/elements/1.1/');
    var RDF = $rdf.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
    var LDP = $rdf.Namespace('http://www.w3.org/ns/ldp#');
    //var myOntology = $rdf.Namespace('http://user.pds.org/ontology/'); 
    var VCARD = $rdf.Namespace('http://www.w3.org/2006/vcard/ns#');

    var evs = g.statementsMatching(undefined, RDF('type'), VCARD('Individual'));
    if (evs != undefined) {
        for (var e in evs) {
            var id = evs[e]['subject']['value'];
            var fullname = g.anyStatementMatching(evs[e]['subject'], VCARD('fn'))['object']['value'];
            var email = g.anyStatementMatching(evs[e]['subject'], VCARD('hasEmail'))['object']['value'];
            var phone = g.anyStatementMatching(evs[e]['subject'], VCARD('hasTelephone'))['object']['value'];

            var contact = {
                id: id.slice(id.length-1),
                Name: fullname,
                Email: email,
                Phone: phone 
            };

            $scope.contacts.push(contact);
        }

    }

    $scope.apply();

    });

};

感谢。

0 个答案:

没有答案