我有这个单选按钮,在页面加载时选中:
<input ng-init="model.PeriodType = 'Accounting Period'"
name="accperiodradio"
id="accperiod"
type="radio"
ng-model="model.PeriodType"
value="Accounting Period" />
和这个更改事件处理程序:
$scope.$watch('model.PeriodType', function (value) {
if (value == 'Accounting Period') {
//do stuff
}
}
});
该$scope.$watch函数在选择另一个单选按钮然后选择会计期间单选按钮时触发,但在页面加载时不会触发,因为它默认被选中。
如何$scope.$watch在页面加载时执行该功能?