我需要类似于这个例子的东西
我用它来嘲笑这个 (function(){ '使用严格的';
角 .module(' MyApp的') .controller(' MyCtrl',ProjectVariablesController);
MyCtrl.$inject = ['$scope', '$state', '$filter', '$http', 'entity'];
function MyCtrl($scope, $state, $filter, $http, entity) {
var vm = this;
vm.project = entity;
$scope.users = [
{id: 1, name: 'awesome user1', status: 2, group: 4, groupName: 'admin'},
{id: 2, name: 'awesome user2', status: undefined, group: 3, groupName: 'vip'},
{id: 3, name: 'awesome user3', status: 2, group: null}
];
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.checkName = function(data, id) {
if (id === 2 && data !== 'awesome') {
return "Username 2 should be `awesome`";
}
};
$scope.saveUser = function(data, id) {
//$scope.user not updated yet
angular.extend(data, {id: id});
return $http.post('/saveUser', data);
};
// remove user
$scope.removeUser = function(index) {
$scope.users.splice(index, 1);
};
// add user
$scope.addUser = function() {
$scope.inserted = {
id: $scope.users.length+1,
name: '',
status: null,
group: null
};
$scope.users.push($scope.inserted);
};
}
})();
因此,细胞编辑不起作用。经过一些实验,我明白我没有像示例中那样具有xeditable依赖性
var app = angular.module(" app",[" xeditable"," ngMockE2E"]);
虽然我已经预先定义了" app"模块,我该如何添加xeditable?
答案 0 :(得分:0)
由于您已经在角度应用中注入了模块xeditable
,因此您还需要在HTML页面中加入xeditable
:
<script src="http://vitalets.github.io/angular-xeditable/dist/js/xeditable.js"></script>
答案 1 :(得分:0)
只需从here下载Xeditable lib并将其包含在index.html主文件中。然后在app.js中将其添加为依赖项。然后示例应该可以正常工作。