Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm creating a Content App which is only usable if the document is saved. I've created a controller using:
var contentForm = angular.element('form[name=contentForm]').scope().contentForm; $scope.$watch(function watch(scope) { return contentForm.$dirty; }, function handle(newValue, oldValue) { vm.ContentSaved = !newValue; }, true);
This works great in developmentmode but when the site is publised to our production environment, the follow error is show in the console:
"angular.element('form[name=contentForm]').scope(...) is undefined"
The differcence between development and production is it's using DependencyHandler.axd
What can be a reason that the angular.element('form[name=contentForm]').scope() not exists when using the DependencyHandler?
Best regards,
iNETZO
Hi @iNETZO, I think this issue is regarding https://github.com/angular/angular.js/issues/9515
did you came across solution to this problem? we are having same issue too.
Hi Pagggy,
In my case i only wanted to know if the form was dirty. I changed the code to this:
var contentForm = angular.element('form[name=contentForm]'); $scope.$watch(function watch(scope) { return contentForm.attr('class'); }, function handle(newValue, oldValue) { var isDirty = newValue.includes("ng-dirty"); vm.ContentSaved = !isDirty; if (editorState.current.id == 0) { vm.ContentSaved = false; } }, true );
Maybe not the best method, i don't like watches but i was under time pressure.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
angular.element('form[name=contentForm]').scope() undefined only in production
Hi,
I'm creating a Content App which is only usable if the document is saved. I've created a controller using:
This works great in developmentmode but when the site is publised to our production environment, the follow error is show in the console:
The differcence between development and production is it's using DependencyHandler.axd
What can be a reason that the angular.element('form[name=contentForm]').scope() not exists when using the DependencyHandler?
Best regards,
iNETZO
Hi @iNETZO, I think this issue is regarding https://github.com/angular/angular.js/issues/9515
did you came across solution to this problem? we are having same issue too.
Hi Pagggy,
In my case i only wanted to know if the form was dirty. I changed the code to this:
Maybe not the best method, i don't like watches but i was under time pressure.
is working on a reply...