我正在使用angucomplete-alt来显示下拉搜索.它的工作正常.但在一种情况下,我想从控制器设置其值.我试过了
$scope.selectedCustomer.title = $scope.customerList[1].businessName
Run Code Online (Sandbox Code Playgroud)
还有
$scope.selectedMerchant = $scope.merchantList[1]
Run Code Online (Sandbox Code Playgroud)
但两者都没有用.在angucomplete-alt文档中,它写有两种方式绑定.任何人都可以帮我显示默认选择..
不确定你是否找到了答案,但我想我会分享我是如何实现这一目标的.
<angucomplete-alt id="owner"
placeholder="user@example.com"
pause="400"
selected-object="subscription.EmailAddress"
initial-value="{{subscription.EmailAddress}}"
Run Code Online (Sandbox Code Playgroud)
初始值接受一个字符串值,使用角度语法我能够使用大括号从控制器生成它.
希望这可以帮助.
我正在使用angucomplete-alt和ui-bootstrap的模态我尝试了很多,最后这样做:
$timeout(function(){
$scope.$broadcast('angucomplete-alt:changeInput', 'myType', myTypeVal);
}, 200);
Run Code Online (Sandbox Code Playgroud)
..和HTML是
<angucomplete-alt id="myType" placeholder="My Type"
pause="400" selected-object="myTypeSelectedFn"
remote-url="/searchMyType"
remote-url-request-formatter="searchMyTypeFn"
search-fields="name" title-field="code"
input-class="form-control form-control-small"
match-class="angucomplete-highlight"
name="myType" minlength="1" field-required="true"
field-required-class="alert-danger"
text-searching="Fetching.." auto-match="true"
ng-model="modifiedMy.type"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7263 次 |
| 最近记录: |