首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ng-角js中的选项问题

ng-角js中的选项问题
EN

Stack Overflow用户
提问于 2017-05-31 15:07:55
回答 1查看 46关注 0票数 0

我是角js的新手,并试图添加选项来选择使用角,但面临的问题:

以下是代码

代码语言:javascript
复制
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

var mymodule = angular.module("firstform",['$scope']);


mymodule.controller("selectgroupcontroller",['$scope', function($scope){
        
       // $scope.optgrps = selectGroupFactory.optgrps;
        $scope.optgrps = [
                                {name : 'First', value : '1', group : '1-3'},
                              {name : 'Second', value : '2', group : '1-3'},
                              {name : 'Third', value : '3', group : '1-3'},
                              {name : 'Fourth', value : '4', group : '4-6'},
                              {name : 'Fifth', value : '5', group : '4-6'},
                              {name : 'Sixth', value : '6', group : '4-6'},
                              
                              
                             ] ;
}]); 
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="row" ng-app="firstform">
  <div class="col-sm-12">
    <form name="selecttest" novalidate="" ng-controller="selectgroupcontroller">
      <div class="form-group">
        <div class="control-label text-center col-sm-2">
          <label for="selectgrp">Select Value: </label>
        </div>
        <div class="col-sm-10">
          <select class="form-control" ng-model="selectedVal" id="selectgrp" ng-options="val.value as (val.name+val.value) group by val.group for val in optgrps">

          </select>
        </div>
      </div>
    </form>


  </div>
</div>

代码很容易为选择选项和打印添加组。但是它没有给出任何错误,也没有给出任何输出。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-31 15:19:12

它给出了错误Error: [$injector:modulerr]删除$scope模块注入

代码语言:javascript
复制
var mymodule = angular.module("firstform",[]);

代码语言:javascript
复制
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

var mymodule = angular.module("firstform",[]);


mymodule.controller("selectgroupcontroller",['$scope', function($scope){
        
       // $scope.optgrps = selectGroupFactory.optgrps;
        $scope.optgrps = [
                                {name : 'First', value : '1', group : '1-3'},
                              {name : 'Second', value : '2', group : '1-3'},
                              {name : 'Third', value : '3', group : '1-3'},
                              {name : 'Fourth', value : '4', group : '4-6'},
                              {name : 'Fifth', value : '5', group : '4-6'},
                              {name : 'Sixth', value : '6', group : '4-6'},
                              
                              
                             ] ;
}]); 
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="row" ng-app="firstform">
  <div class="col-sm-12">
    <form name="selecttest" novalidate="" ng-controller="selectgroupcontroller">
      <div class="form-group">
        <div class="control-label text-center col-sm-2">
          <label for="selectgrp">Select Value: </label>
        </div>
        <div class="col-sm-10">
          <select class="form-control" ng-model="selectedVal" id="selectgrp" ng-options="val.value as (val.name+val.value) group by val.group for val in optgrps">

          </select>
        </div>
      </div>
    </form>


  </div>
</div>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44288389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档