使用Angularjs的绑定问题
我正在尝试根据dropdownlist的选定值动态绑定使用Angularjs的绑定问题,angularjs,Angularjs,我正在尝试根据dropdownlist的选定值动态绑定。 这是我的app.js var app = angular.module('app',['ui.bootstrap']); app.controller('tabCtrl',function($scope,$http){ $scope.countryList=[{name:'Canada',id:'ca'},{name:'United States',id:'us'}]; $scope.selectedCountry =$s
var app = angular.module('app',['ui.bootstrap']);
app.controller('tabCtrl',function($scope,$http){
$scope.countryList=[{name:'Canada',id:'ca'},{name:'United States',id:'us'}];
$scope.selectedCountry =$scope.countryList[1].id;
$scope.init = function() {
$scope.countries =[{countryName:"ca"},{countryName:"us"}];
$scope.countries[0].tabs=[{title:"CA Title 1"},{title:"CA Title 2"}];
$scope.countries[1].tabs=[{title:"US Title 1"},{title:"US Title 2"}];
};
$scope.switch = function(){
console.log($scope.selectedCountry);
}
});
这是我的jsp页面
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html ng-app="app">
<head>
<script src="<c:url value="/resources/javascript/angular.min.js" />"></script>
<script src="<c:url value="/resources/javascript/ui-bootstrap-tpls-0.12.0.min.js" />"></script>
<script src="<c:url value="/resources/javascript/app.js"/>"></script>
<link href="<c:url value="/resources/style/bootstrap.min.css" />" rel="stylesheet">
<title></title>
</head>
<body>
<br />
<div ng-controller="tabCtrl" >
<!--<select ng-model="selectedCountry" ng-options="c.id as c.name for c in countryList" ng-change="switch()" />-->
<form name="frm" ng-submit="submit()" data-ng-init="init()">
<div ng-repeat="c in countries|filter:{countryName:selectedCountry}">
<tabset>
<tab ng-repeat="t in c.tabs" heading="{{t.title}}">
</tab>
</tabset>
</div>
<button class="btn btn-primary" type="submit">Submit</button>
</form>
</div>
</body>
</html>
我有两个绑定,一个用于dropdownlist,一个用于tabset。
我的问题是,如果我添加