我尝试先运行ng-clik并在等待1秒后尝试加载表单页面..如果我尝试像这样的波纹管代码有时ng-click工作有时可能ui-sref ..我使用timeOut但是没有不做任何改变。
<ul class="list-unstyled components" >
<li ng-repeat-start="item in Menus">
<a ng-click="GetFormByMenu(item)" ui-sref="form" >{{item.DetailName}}</a>
</li>
<li ng-repeat-end></li>
</ul>
以下是JavaScript代码:
app.controller('myController', function ($scope, Services, BilesenServices)
{
$scope.GetFormByMenu = function (Model) {
$scope.text = '1';
BilesenServices.GetBilesenByMenuId(Model.Id).then(function (response) {
$scope.startLabel = response.data.startLabel;
$scope.endLabel = response.data.endLable;
$scope.startTimePaker = response.data.startDateTimePaker;
$scope.endTimePaker = response.data.endDateTimePaker;
$scope.textBox = response.data.TextBox;
$scope.musteriLabel = response.data.cNolabel;
console.log(response.data.startLabel);
// alert("Herer");
}, function (error) {
alert("Error" + error);
});
}
}
答案 0 :(得分:0)
您可以从控制器进行状态更改(ui-sref
)。
在您的情况下,您可以将代码更改为:
app.controller('myController', function($scope, $state, Services, BilesenServices) {
$scope.GetFormByMenu = function(Model) {
$scope.text = '1';
BilesenServices.GetBilesenByMenuId(Model.Id).then(function(response) {
$scope.startLabel = response.data.startLabel;
$scope.endLabel = response.data.endLable;
$scope.startTimePaker = response.data.startDateTimePaker;
$scope.endTimePaker = response.data.endDateTimePaker;
$scope.textBox = response.data.TextBox;
$scope.musteriLabel = response.data.cNolabel;
console.log(response.data.startLabel);
// alert("Herer");
$state.go("form"); // you can go to any state you want, even with parameters
}, function(error) {
alert("Error" + error);
});
}
});
&#13;
<ul class="list-unstyled components">
<li ng-repeat-start="item in Menus">
<a ng-click="GetFormByMenu(item)" href="#">{{item.DetailName}}</a>
</li>
<li ng-repeat-end>
</li>
</ul>
&#13;
并从html中删除ui-sref
。如果您还没有,请不要忘记将 $ state 注入您的控制器。