我有这样的HTML:访问UI元素
<select id="common_commonbundle_standard_address_country"
ng-model="common_commonbundle_standard_address.country"
required="required"
tooltip="País"
tooltip-trigger="focus"
tooltip-placement="right"
wv-def="País"
wv-cur=""
wv-err="Error!"
wv-req="The value you selected is not a valid choice"
type="text"
class="ng-scope ng-dirty ng-valid ng-valid-required">
...
</select>
而且我使用此代码试图common_commonbundle_standard_address.country
要监视更改:
$scope.$watch('$scope.common_commonbundle_standard_address.country', function(iso_country) {
if (iso_country)
$http.get(Routing.generate('states') + iso_country).success(function(data) {
if (data.message) {
$scope.message = data.message;
} else {
$scope.states = data;
}
}).error(function(data, status, headers, config) {
if (status == '500') {
$scope.message = "No hay conexión con el servidor.";
}
});
});
但它不工作,有什么我做错了?
新增控制器
app.controller( 'NewSeller',函数($范围,$ HTTP,$ routeParams,$ fileUploader){
$scope.section = $routeParams.section == undefined ? 'main' : $routeParams.section;
$scope.aaaa = 'sdsdsdsd';
switch ($scope.section) {
case 'registro':
{
$('.seller-menu').animate({left: -230}, 300);
$scope.section = 'primer-paso';
break;
}
case 'segundo-paso':
{
break;
}
case 'main':
default:
{
break;
}
}
// Add watch for states
$scope.$watch('common_commonbundle_standard_address.country',
function(iso_country) {
$http.get(Routing.generate('states') + iso_country).success(function(data) {
if (data.message) {
$scope.message = data.message;
} else {
$scope.states = data;
}
}).error(function(data, status, headers, config) {
if (status == '500') {
$scope.message = "No hay conexión con el servidor.";
}
});
}, true);
});
您是否使用了调试器来查看您的处理程序是否被调用或者处理程序中是否有错误? –
'$ scope.common_commonbundle_standard_address.country'应该是'common_commonbundle_standard_address.country' – Whisher