1

select(ngOptions) を含むフォームからモデルを解析してデータベースに保存しようとしていますが、選択した値は解析されません。私はここで立ち往生しています。誰か助けてください。

ここに私のコードがあります:

意見

<section class="container" data-ng-controller="TagsController" >
    <h2><i class="fa fa-pencil-square-o"></i>Add a new Tag</h2>

    <form class="form-horizontal col-md-5" data-ng-submit="create()">
        <div class="form-group ">
            <div class="controls">
                <input type="text" class="form-control input-lg" data-ng-model="label" id="label" placeholder="Label" required>
            </div>
        </div>
        <div class="form-group" data-ng-controller="CategoriesController" data-ng-init="find()">
            <select class="form-control input-lg" ng-model="category._id" ng-options="category._id as category.label for category in categories">
              <option value="">Choose a Category</option>
            </select>
        </div>

        <div class="control-group">
            <div class="controls">
                <input type="submit" class="btn">
            </div>
        </div>

    </form>
</section>

コントローラ

angular.module('mean.tags').controller('TagsController', ['$scope', '$routeParams', '$location', 'Global', 'Tags', function ($scope, $routeParams, $location, Global, Tags) {
    $scope.global = Global;

    $scope.create = function() {
        var tag = new Tags({
            label: this.label,
            category: this.category
        });
        tag.$save(function(response) {
            $location.path("tags/");
        });
        this.label = "";
        this.category = "";
    };
...
4

1 に答える 1

0

問題を見つけたので、質問に答えます。問題はアーキテクチャの制限によるもので、Angularjs では ng-controller を他のコントローラー内にネストすることはできません...

于 2014-01-12T21:19:32.143 に答える