programing

TypeError: $scope.apply는 함수가 아닙니다.

telecom 2023. 3. 16. 21:08
반응형

TypeError: $scope.apply는 함수가 아닙니다.

연락처 목록을 검색한 후 렌더링하려고 합니다.rdflib.js. 정상적으로 로딩되어 스코프 내 리스트에 저장되고 있습니다.

그러나 $scope가 업데이트되지 않아 렌더링할 수 없습니다.콜을 하고 있는 것 같습니다.$scope.apply()잘못된 장소에.이 에러는 angular 외부라고 부르기 때문에 발생합니다만, 일부러 angular 콘텍스트 외부에 있는 함수 내부에서 호출하고 있습니다(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();

    });

};

함수는$apply(), 및$.

언급URL : https://stackoverflow.com/questions/28307345/typeerror-scope-apply-is-not-a-function

반응형