在Angular中,我可能會(huì)有一個(gè)如下形式的表單:<ng-form> <label>First Name</label> <input type="text" ng-model="model.first_name"> <label>Last Name</label> <input type="text" ng-model="model.last_name"></ng-form>在相應(yīng)的控制器內(nèi),我可以輕松地監(jiān)視該表單內(nèi)容的更改,如下所示:function($scope) { $scope.model = {}; $scope.$watch('model', () => { // Model has updated }, true);}我在弄清楚如何在Angular中完成相同的事情時(shí)遇到了麻煩。顯然,我們不再擁有$scope$ rootScope。當(dāng)然,有一種方法可以完成同一件事?
如何在Angular中觀察表單更改
繁星點(diǎn)點(diǎn)滴滴
2019-12-12 13:43:45