I'm creating a property editor and would like to fire a function when the user changes the name of the item currently being edited. I tried to do $scope.$watch but that doesn't seem to be working:
Sorry for necrocommenting, but I have a similar problem with that. When you adding the editorState to scope its invokes so many times and it bother me a liitle, it is possible edditorState disturbing database so many times.
Angular : how to get item name changes
Hi,
I'm creating a property editor and would like to fire a function when the user changes the name of the item currently being edited. I tried to do $scope.$watch but that doesn't seem to be working:
Here is my controller code :
angular.module("umbraco") .controller("MyPropertyEditorController", function ($scope, editorState) { $scope.model.value.myprop = editorState.current.name; $scope.$watch('editorState.current.name', function() { $scope.model.value.myprop = editorState.current.name; }); });I found out how to do it :
I added the editor state to the scope and then it works fine
angular.module("umbraco") .controller("MyPropertyEditorController", function ($scope, editorState) { $scope.editorState = editorState; $scope.model.value.myprop = $scope.editorState.current.name; $scope.$watch('editorState.current.name', function(newVal) { $scope.model.value.myprop = newVal; }); });Sorry for necrocommenting, but I have a similar problem with that. When you adding the editorState to scope its invokes so many times and it bother me a liitle, it is possible edditorState disturbing database so many times.
What do you think about it?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.