Angularjs查询网址参数没有设置 [英] Angularjs query url parameter not set

查看:96
本文介绍了Angularjs查询网址参数没有设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林我Angularjs-App中的查询URL参数datenbestand未设置:datenbestand = undefinded。来源$ C ​​$ C如下。

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>

控制器

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();
    };
}
]  );

服务:

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?

推荐答案

我是新来的角,但我想知道你是怎么想你的工厂越来越为 datenbestand 。我相信你的问题是范围之一。当我做类似的code的东西,它没有看到它,除非我专门通过它,比如与服务,或使在同一范围内调用。

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.

我相信<一个href=\"http://stackoverflow.com/questions/13313971/at-sign-in-parameter-names-in-resource-definition/13314014#13314014\">this帖子可能有助于虽然回答你的问题。希望有所帮助。

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

这篇关于Angularjs查询网址参数没有设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆