如何从控制器绑定模型?
这是我的代码
angular.module('elnApp')
.controller('GridCtrl', function ($scope, $http, $routeParams, $location,
programService) {
$scope.gridOptions = {
data: 'myData',
enablePaging: true,
showFooter: true,
totalServerItems:'totalServerItems',
pagingOptions: $scope.pagingOptions,
filterOptions: $scope.filterOptions,
selectedItems: $scope.mySelections,
multiSelect: false,
afterSelectionChange: function (data) {
$scope.program = $scope.mySelections[0];
$scope.program = $scope.mySelections[0].programId;
programService.get({
id: $scope.program
}, function (result) {
data = {
'program': result
};
});
$location.path('/program/edit/'+$scope.program);
}
};});
编辑html
<form ng-submit="save()">
<input type="hidden" ng-model="program.program.programId"/>
<dl>
<dt>Program Name</dt>
<dd><input name="programName" type="text" ng-model="program.program.programName"/></dd>
<dt>Program Content</dt>
</dl>
<div class="form-actions">
<button type="submit">Save</button>
</div>
当我在切换页面编辑html后选择项目时,我无法绑定模型?
我对此感到很困惑,请帮助