rickbutterfield / Umbraco.Community.BlockPreview

Easy to use rich HTML backoffice previews for the Umbraco Block List and Block Grid editors.
MIT License
15 stars 10 forks source link

undefined error in controller #28

Closed robertjf closed 1 year ago

robertjf commented 1 year ago

On Umbraco v12.1.2 with the latest release:

I've installed and configured some of the Blocks as detailed in the readme, and when I view a content node in the Backoffice I get an undefined error on the following line in the controller (line 22):

TypeError: Cannot read properties of undefined (reading 'model')
    at Object.<anonymous> (block-preview.controller.js?d=638293026850000000:22:113)
    at Object.invoke (angular.js:5208:16)
    at S.instance (angular.js:11814:24)
    at p (angular.js:10627:33)
    at g (angular.js:9942:13)
    at angular.js:9807:30
    at Object.link (angular.js:29993:9)
    at angular.js:1391:15
    at Ca (angular.js:11376:9)
    at p (angular.js:10695:11) '<div class="umb-block-list__block--view ng-scope" ng-include="model.view">'

The line throwing the error is this:

            // There must be a better way to do this...
            $scope.blockEditorAlias = $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.vm.model.editor;

I don't think there's anything special about this block, it's not nested in anything either. The last $parent is an object, but the vm property isn't.

rickbutterfield commented 1 year ago

Hey @robertjf! There was a bug in 1.6.0, please try upgrading to 1.6.1 and see if that resolves your issue.

robertjf commented 1 year ago

Much better - thanks :)