对于基于 AngularJS、JQuery Mobile 和 JQuery Mobile Angular Adapter 的应用程序。
当我在带有 data-role="page" 的标签上设置 ng-controller 时,选择标签上的 ng-model 可以完美运行:
<body ng-app>
<div data-role="page" id="product" ng-controller="Controller">
<div data-role="content">
<select ng-model="color" ng-options="c for c in colors"></select>
<button ng-click="Print()">print</button>
http://jsfiddle.net/ilya7u/Ddt7G/
当 ng-controller 出现在 body 标签中时,通过 ng-model 与 select 标签关联的变量保持不变:
<body ng-app ng-controller="Controller">
<div data-role="page" id="product">
<div data-role="content">
<select ng-model="color" ng-options="c for c in colors"></select>
http://jsfiddle.net/ilya7u/qgbj2/
为什么以及如何解决?我想在有很多页面的应用程序中使用一个控制器!