AngularJS - jQuery - ui - sortable g.sortable 不是函数
AngularJS - jQuery - ui-sortable g.sortable is not a function
我正在 ui-sortable
的帮助下创建一个带有可拖动行的 table
<tbody ui-sortable="sortableOptions" ng-model="model.list">
<tr ng-repeat="item in model.list">
<td>
<div class="form-group">
<input type="text" class="form-control test-input" ng-model="item.Country" ng-readonly="!isEditable">
</div>
</td>
<td>
<div class="form-group">
<input type="text" class="form-control test-input" ng-model="item.Value" ng-readonly="!isEditable">
</div>
</td>
</tr>
这是控制器中的代码。
$scope.sortableOptions = {
update: function(e, ui) {
console.log(model.list);
},
stop: function(e, ui) {
console.log(model.list);
}
};
我已经使用了require.js并且在那边添加了依赖ui.sortable
。
每当我打开带有此 table 的页面时,我都会收到此错误 -
angular.js:12520
TypeError: g.sortable is not a function
at w (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:4649)
at x (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:4721)
at link (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:5003)
at http://localhost:90/bower_components/angular/angular.js:8835:44
at invokeLinkFn (http://localhost:90/bower_components/angular/angular.js:8841:9)
at nodeLinkFn (http://localhost:90/bower_components/angular/angular.js:8335:11)
at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7731:13)
at nodeLinkFn (http://localhost:90/bower_components/angular/angular.js:8330:24)
at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7731:13)
at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7734:13) <tbody ui-sortable="sortableOptions" ng-model="model.list" class="ng-pristine ng-untouched ng-valid ng-isolate-scope">
你能帮帮我吗?
提前致谢
ui-可排序取决于jQuery、jQuery UI 1.9+。在 ui-sortable js 文件之前检查你是否有这些依赖,那么你应该在正确的模块 angular.module('myapp', ['ui.sortable']);
中注入 ui.sortable
遇到同样问题但似乎一切都正确的人;
1. jQuery is loaded.
2. angular-ui-sortable is being loaded correctly.
3. You've injected its dependency.
angular.module('myapp', ['ui.sortable']);
4. The code appears to be correct in the view
确保在 jquery
之后和 sortable
js 文件之前包含 jquery-ui
。我遇到了同样的问题 运行,在头痛不已之后找到了这个解决方案 here in this thread。
我正在 ui-sortable
的帮助下创建一个带有可拖动行的 table<tbody ui-sortable="sortableOptions" ng-model="model.list">
<tr ng-repeat="item in model.list">
<td>
<div class="form-group">
<input type="text" class="form-control test-input" ng-model="item.Country" ng-readonly="!isEditable">
</div>
</td>
<td>
<div class="form-group">
<input type="text" class="form-control test-input" ng-model="item.Value" ng-readonly="!isEditable">
</div>
</td>
</tr>
这是控制器中的代码。
$scope.sortableOptions = {
update: function(e, ui) {
console.log(model.list);
},
stop: function(e, ui) {
console.log(model.list);
}
};
我已经使用了require.js并且在那边添加了依赖ui.sortable
。
每当我打开带有此 table 的页面时,我都会收到此错误 -
angular.js:12520
TypeError: g.sortable is not a function
at w (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:4649)
at x (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:4721)
at link (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:5003)
at http://localhost:90/bower_components/angular/angular.js:8835:44
at invokeLinkFn (http://localhost:90/bower_components/angular/angular.js:8841:9)
at nodeLinkFn (http://localhost:90/bower_components/angular/angular.js:8335:11)
at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7731:13)
at nodeLinkFn (http://localhost:90/bower_components/angular/angular.js:8330:24)
at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7731:13)
at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7734:13) <tbody ui-sortable="sortableOptions" ng-model="model.list" class="ng-pristine ng-untouched ng-valid ng-isolate-scope">
你能帮帮我吗? 提前致谢
ui-可排序取决于jQuery、jQuery UI 1.9+。在 ui-sortable js 文件之前检查你是否有这些依赖,那么你应该在正确的模块 angular.module('myapp', ['ui.sortable']);
遇到同样问题但似乎一切都正确的人;
1. jQuery is loaded.
2. angular-ui-sortable is being loaded correctly.
3. You've injected its dependency.
angular.module('myapp', ['ui.sortable']);
4. The code appears to be correct in the view
确保在 jquery
之后和 sortable
js 文件之前包含 jquery-ui
。我遇到了同样的问题 运行,在头痛不已之后找到了这个解决方案 here in this thread。