我有 3 个选项卡:客户、计费和方法。在第一个选项卡上,我有 Bootstrap Typeahead,它连接到客户的 json 文件。第二个选项卡是未结费用的客户帐户的详细视图。最后,第三个选项卡是用信用卡实际向客户收费。此外,我正在使用 UI 路由器在复杂的层次结构中导航。这些选项卡是名为 make-payments 的页面的命名视图,该页面是名为 payment 的父状态的子状态。我正在尝试使用第一个选项卡(客户)中的预输入来选择和查看第二个选项卡(计费)中的客户详细信息。我希望当用户从下拉列表中选择人员时会发生这种情况,他们应该立即导航到下一个选项卡,并且下一个选项卡应该显示该人员的详细信息。
make-payment.html(我的标签):
<h3 class="text-center">Make a One-Time Payment</h3>
<uib-tabset type="pills nav-pills-centered">
<uib-tab heading="1">
<div ui-view=customers></div>
</uib-tab>
<uib-tab heading="2">
<div ui-view=billing></div>
</uib-tab>
<uib-tab heading="3">
<div ui-view=method></div>
</uib-tab>
</uib-tabset>
customers.html 和 typeahead.js 控制:
angular
.module('myApp')
.controller('TypeAheadCtrl', function($scope, $http) {
$http.get('customers.json').success(function(data) {
$scope.customers = data;
});
var self = this;
self.submit1 = function() {
console.log('First form submit with', self.customer)
};
});
<div ng-controller="TypeAheadCtrl as ctrl">
<form ng-submit="ctrl.submit1()" name="customerForm">
<div class="form-group">
<label for="account">Account Number</label>
<input type="text" class="form-control" placeholder="Search or enter an account number" ng-model="ctrl.customer.account" uib-typeahead="customer as customer.index for customer in customers | filter:$viewValue | limitTo:6" typeahead-template-url="templates/customer-tpl.html"
typeahead-no-results="noResults">
</div>
</form>
</div>
app.js(我有 ui-router 的东西)
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/payments/make-payment');
$stateProvider
// HOME STATES AND NESTED VIEWS ========================================
.state('payments', {
url: '/payments',
templateUrl: 'views/payments.html'
})
.state('activity', {
url: '/activity',
templateUrl: 'views/activity.html'
})
// nested lists
.state('payments.make-payment', {
url: '/make-payment',
views: {
'': {
templateUrl: 'views/make-payment.html'
},
'customers@payments.make-payment': {
templateUrl: 'views/customers.html'
},
'billing@payments.make-payment': {
templateUrl: 'views/billing.html'
},
'method@payments.make-payment': {
templateUrl: 'views/method.html'
});
});
计费.html
<p>{{ctrl.customer.account.name}}</p>
<p>{{ctrl.customer.account.address}}</p>
<p>{{ctrl.customer.account.email}}</p>
<p>{{ctrl.customer.account.phone}}</p>