Javascript Angularjs ui选项卡集范围未更新
我正在使用angular ui引导中的选项卡。 所有工作正常,但我注意到选项卡内的文本框并没有更新范围,尽管使用了ng模型 我搜索并发现这是因为子范围,建议在绑定时使用obj.property表示法 但我的模型仍然没有更新 请告诉我哪里出了问题Javascript Angularjs ui选项卡集范围未更新,javascript,angularjs,angular-ui-bootstrap,Javascript,Angularjs,Angular Ui Bootstrap,我正在使用angular ui引导中的选项卡。 所有工作正常,但我注意到选项卡内的文本框并没有更新范围,尽管使用了ng模型 我搜索并发现这是因为子范围,建议在绑定时使用obj.property表示法 但我的模型仍然没有更新 请告诉我哪里出了问题 wbProcess.controller ("createProCtrl", function ($scope, $http, global, user){ $scope.project = [{protitle :""},
wbProcess.controller ("createProCtrl", function ($scope, $http, global, user){
$scope.project = [{protitle :""},
{prodesc : ""},
{chkarchive : false}
];
$scope.tab = true;
$scope.upurl;
$scope.createpro = function(){
$http({
url: global.apiurl+"pro/create",
method: "POST",
data: {'name': $scope.project.protitle, 'prodesc': $scope.project.prodesc, 'owner': user.user_id , 'active': $scope.project.chkarchive}
}).success(function (data, status, headers, config) {
// assign $scope.persons here as promise is resolved here
//$log.log(data);
if(data.status > 0){
$scope.tab = false;
}
else{
}
}).error(function (data, status, headers, config) {
$scope.status = status;
$log.log(status);
});
}
});
HTML是
<tabset>
<tab>
<tab-heading>
<i class="green icon-edit bigger-110"></i>Description
</tab-heading>
<div>
<form name="createProForm" class="form-horizontal">
<div class="control-group span7">
<label class="control-label" for="form-field-1">Title</label>
<STYLE type="text/css">
.ng-dirty.ng-valid ~ span.ok { color:green; display:inline; }
.ng-dirty.ng-invalid ~ span.ko { color:red; display:inline; }
</STYLE>
<div class="controls">
<input type="text" name="protitle" id="projecttitle" ng-model="project.protitle" ng-unique="projects" placeholder="Title" required />
<span class="red" ng-show="createProForm.protitle.$error.unique" >
<i class="red icon-asterisk bigger-110"></i> Project Title already exists.</span>
<!--<span class="green" ng-show="createProForm.protitle.$error.unique === false" >
<i class="green icon-asterisk bigger-110"></i> Available</span>
-->
</div>
</div>
<div class="control-group span5">
<div class="controls">
<input class="ace" type="checkbox" id="id-disable-check" ng-model="project.chkarchive" tabindex="-1"/>
<label class="lbl" for="id-disable-check"> Archive Project</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="form-field-9">Project Description</label>
<div class="controls">
<textarea class="span7" id="projecttitle" ng-model="project.prodesc" maxlength="100" placeholder="100 Character Limit" required></textarea>
</div>
</div>
<div class="form-actions">
<button class="btn btn-info" type="button" ng-disabled="createProForm.protitle.$pristine || createProForm.protitle.$dirty && createProForm.protitle.$error.unique === true" ng-click="createpro()">
<i class="icon-ok bigger-110"></i>
Save
</button>
<button class="btn" type="reset">
<i class="icon-undo bigger-110"></i>
Reset
</button>
<button class="btn btn-default btn-sm" ng-click="tabs[1].disabled = ! tabs[1].disabled">Enable / Disable third tab</button>
</div>
</form>
</div>
</tab>
<tab disabled = "tab">
<tab-heading>
<i class="green icon-cogs bigger-110"></i>Configuration
</tab-heading>
<div>
<div class="span6">
hi
</div>
<div id="dropzone" class="span6">
<input type="hidden" id="upurl" value="{{ upurl }}" />
<form action="/not-found" class="dropzone">
<div class="fallback">
<input name="file" type="file" multiple/>
</div>
</form>
</div>
</div>
</tab>
<tab disabled = "tab">
<tab-heading>
<i class="green icon-group bigger-110"></i>Users
</tab-heading>
<div>
<p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade.</p>
</div>
</tab>
描述
标题
.ng-dirty.ng-valid~span.ok{颜色:绿色;显示:内联;}
.ng-dirty.ng-invalid~span.ko{颜色:红色;显示:内联;}
项目标题已存在。
档案项目
项目说明
拯救
重置
启用/禁用第三个选项卡
配置
你好
使用者
Etsy混音带旅行者,道德的wes anderson豆腐,然后将mcsweeney的有机lomo retro fanny pack lo-fi农场出售给桌上成衣商
文本输入仅在第一个选项卡中。有一个解决方案可以访问它。 您可以在控制器中使用以下语法访问它。 $scope.$$childHead.$$nextSibling.yourVariablename 例如,在html页面上有ng model=“state”,您可以像这样访问它
$scope.$$childHead.$$nextSibling.state由于子作用域而在绑定时使用obj.property表示法的建议是正确的,但您错误地将
$scope.project
定义为对象的列表,而不仅仅是具有多个键/值对的简单对象
尝试:
另见
$scope.project = {
protitle: "",
prodesc : "",
chkarchive: false
};