Blu*_*Blu 4 javascript jquery jquery-mobile angularjs
我正在使用AngularJS和JQM我创建了一个下拉列表,用于使用AngularJS Controller选择其中的值和数据.它工作正常,但是当我添加data-native-menu="false 的<select>那么奇怪处决我选择它选择的第二第一个值.
我的HTML部分
<div ng-controller="MyCtrl">
<select data-native-menu="false" data-role="listview" ng-options="size as size.name for size in sizes " ng-model="item" ng-change="update()"></select>
{{item.code}} {{item.name}}
</div>
Run Code Online (Sandbox Code Playgroud)
JS部分
myApp.controller('MyCtrl',function($scope){
$scope.sizes = [ {code: 1, name: 'n1'}, {code: 2, name: 'n2'}];
$scope.update = function() {
console.log($scope.item.code, $scope.item.name)
}});
Run Code Online (Sandbox Code Playgroud)
如果我删除data-native-menu="false" data-role="listview"然后代码工作正常
请帮我
我的示例的演示页面就在这里
你可以找到工作代码 Fiddle
HTML
<div ng-controller = "fessCntrl" >
<div query-mobile-tpl>
<select data-role="listview" data-inset="true" ng-options="size as size.name for size in sizes " ng-model="item" x-ng-change="update(item)"></select>
<pre> {{item.code | json}} {{item.name | json}}</pre>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
调节器
var fessmodule = angular.module('myModule', []);
fessmodule.controller('fessCntrl', function ($scope) {
$scope.sizes = [ {code: 1, name: 'n1'}, {code: 2, name: 'n2'}];
$scope.update = function() {
console.log($scope.item.code, $scope.item.name)
};
});
fessmodule.directive('jqueryMobileTpl', function() {
return {
link: function(scope, elm, attr) {
elm.trigger('create');
}
};
});
fessmodule.directive('repeatDone', function () {
return function (scope, element, attrs) {
// When the last element is rendered
if (scope.$last) {
element.parent().parent().trigger('create');
}
}
});
fessmodule.$inject = ['$scope'];
Run Code Online (Sandbox Code Playgroud)
听起来像你使用旧的角度源或与其他来源发生碰撞.
希望它会对你有所帮助