Angularjs query url parameter not set

痞子三分冷 提交于 2019-12-11 21:10:03

问题


Im my Angularjs-App the query url parameter datenbestand is not set: ?datenbestand=undefinded. Source code is as follows.

HTML

<select ng-model="datenbestand" id="datenbestand" name="datenbestand" class="span3 search-query">
                        <option value="A">A</option>
                        <option value="B">B</option>
                    </select>

CONTROLLER

app.controller( 'VListCtrl', [ '$scope', 'personlistdto', 'VListLoader', '$q', 'VService', 
                                          function( $scope, personlistdto, VListLoader, $q, VService  ) {
    $scope.personlistdto = personlistdto;
    $scope.searchFactory = VListLoader;
    $scope.search =  function( ){
        $scope.personlistdto = $scope.searchFactory();
    };
}
]  );

SERVICE:

services.factory( 'VService', [ '$resource',
                            function find( $resource ) {
    return $resource( '/cdemo/rest/vers/ajs/:id',
            { id: '@id', datenbestand: '@datenbestand', isArray: false }
    );
} ] );


services.factory( 'VListLoader', [ 'VService', '$q', '$route', 
                                       function( VService, $q, $route ) {
    var find = function find() {
        var delay = $q.defer();
        VService.get( function( personlistdto ) {
            delay.resolve( personlistdto );
        }, function() {
            delay.reject( 'Unable to fetch v' );
        } );
        return delay.promise;
    };

    return find;
} ] );

What am I doing wrong?


回答1:


I'm new to Angular, but I'm wondering how you think your factory is getting access to datenbestand. I believe your problem is one of scope. When I do something similar to your code, it's not seeing it unless I specifically pass it, such as with a service, or making the call in the same scope.

I believe this post may help answer your question though. Hope that helps.



来源:https://stackoverflow.com/questions/17021626/angularjs-query-url-parameter-not-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!