小编Waj*_*man的帖子

如何修复预期的响应包含一个数组但得到一个对象ANgular js

我很新,在调用服务后使用资源模块很难获得此错误.任何人都可以修改我在错误的代码中的错误,或者只是修改了需要纠正的问题必须得到理解.

数据格式来了: -

[
    brands: Array[1]
    0: Object
    __v: 0
    _id: "5251a4a34f232fc3902"
    account_id: "525072320e32971b"
    name: "Fruits"
    __proto__: Object
    1: Object
    length: 2

    categories: Array[1]
        0: Object
        __v: 0
        _id: "5251a4a34f2323fc3902"
        account_id: "5250723230e32971b"
        name: "Fruits"
        __proto__: Object
        1: Object
        length: 2
]
Run Code Online (Sandbox Code Playgroud)

错误:-

[$ resource:badcfg]资源配置错误.预期的响应包含一个数组但得到一个对象

itmsFormView.html

<select class="form-control" ng-model="item.brand_id" id="itemBrand" >
    <option value="">Select Brand</option>
    <option ng-repeat="brand in brands" value="{{brand.brand_id}}">{{brand.name}}  </option>
</select>



 <select class="form-control" ng-model="item.category_id" id="itemCategory">           

<option value="">Select Category</option>
       <option ng-repeat="category in categories" value="{{category.brand_id}}">{{category.name}}</option>
    </select>
Run Code Online (Sandbox Code Playgroud)

ItemsService.js

app.factory('itemService', function ($resource) {
    return { …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

12
推荐指数
2
解决办法
4万
查看次数

未捕获的错误:没有模块:ngRoute

我正在使用ngRoute模块,但它显示我的错误,所以有额外的文件需要添加使用此模块我搜索但我没有找到像其他模块资源,我们需要单独的文件的cookie我是否为ngroute也如果是的话所以在哪里我能找到这个吗?

错误:-

Uncaught Error: No module: ngRoute 
var app = angular.module('inventoryApp', ['ngCookies','ngResource', 'ngRoute']);
Run Code Online (Sandbox Code Playgroud)

controller.js

app.controller('storesController', function ($rootScope, $scope, $location, $cookies, $routeParams) {

});
Run Code Online (Sandbox Code Playgroud)

angularjs

7
推荐指数
2
解决办法
2万
查看次数

欧芹验证不起作用Angular js

我正在使用角度js进行解析验证,但它无法正常工作,我做错了可以任何人纠正或检测我的代码中的错误.根据他们的属性,如果我提交,那么它的工作没有显示任何错误,就像分析显示一样.我还添加了parsely库,没有得到任何与之相关的错误,所以出了什么问题.

LoginView.html

<form class="form-horizontal" ng-submit='login()' data-validate="parsley">
                <div class="modal-header">
                    <h3>Login</h3>
                </div>

                <div class="modal-body">
                    <div class="form-group">
                        <label for="login-Name" class="col-lg-3 form-label">User Name:</label>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" id="login-Name" ng-model="LoginName" name="login-Name" placeholder="User Name" data-type="alphanum" data-required="true" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="login-Password" class="col-lg-3 form-label">Password:</label>
                        <div class="col-lg-8">
                            <input type="password" class="form-control" id="login-Password" ng-model="LoginPass" name="login-Password" placeholder="Password" data-type="alphanum" data-required="true" data-minlength="6" data-minlength="6" data-maxlength="20"/>
                        </div>
                    </div>
                </div>


                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">
                        <i class="icon-user icon-white"></i> Login
                    </button>
                </div>

            </form>
Run Code Online (Sandbox Code Playgroud)

loginController.js

$scope.login = function() {

          var user = {
              "username" …
Run Code Online (Sandbox Code Playgroud)

angularjs parsley.js

5
推荐指数
1
解决办法
5392
查看次数

使用Pusher API通知特定用户

我有一个使用jquery mobile和phonegap的移动网络应用程序,其他是php网站.我希望只发送通知给在线和移动应用程序的特定用户,在php网站上接收用户在线的通知以及移动网络应用程序所以我的问题是如何为特定用户设置频道,因为现在通知发送给所有用户,这些用户对消息和连接没用.

目前,我的代码向所有人发送通知可以解决这个问题,我的代码需要进行更改.

在事件触发器上我有那个代码php网站.

$message = "User Response Has been Sent For Taxi On way";
            $pusher = new Pusher( APP_KEY, APP_SECRET, APP_ID );
            $data = array('message' => $message);
            $pusher->trigger( 'dispatcher_channel', 'dispatcher_Response', $data );
Run Code Online (Sandbox Code Playgroud)

在移动网络应用程序上,我有该代码.

Pusher.log = function(message) {
          if (window.console && window.console.log) {
            window.console.log(message);
          }
        };

        var pusher = new Pusher('APP_KEY');
        var channel = pusher.subscribe('dispatcher_channel');
        channel.bind('dispatcher_Response', function(data) {
          alert(data.message);
          channel.bind('dispatcher_Response', function(data) {});
        });
Run Code Online (Sandbox Code Playgroud)

javascript php pusher

1
推荐指数
1
解决办法
3555
查看次数

标签 统计

angularjs ×3

javascript ×2

parsley.js ×1

php ×1

pusher ×1