Angularjs query url parameter not set

2019-09-07 02:37发布

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条回答
孤傲高冷的网名
2楼-- · 2019-09-07 03:29

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.

查看更多
登录 后发表回答