Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

"no getter error" with ng-view #1279

Closed
ckyang74 opened this issue Jul 30, 2014 · 2 comments
Closed

"no getter error" with ng-view #1279

ckyang74 opened this issue Jul 30, 2014 · 2 comments

Comments

@ckyang74
Copy link

What steps will reproduce the problem?

  1. In Dart editor, create a new project
  2. Create a controller, a router, a view, and a template
  3. In the template, refer to a controller field (say, ctrl.foo)
  4. Right click on the view (html) and select "View as JavaScript"

What is the expected output? What do you see instead?

Expect to see view + routed template rendered, saw "no getter" exception instead:

No getter for 'ctrl'.

STACKTRACE:
Error
    at dart.wrapException (http://127.0.0.1:8080/sandbox2.dart.js:2489:15)
    at StaticClosureMap.lookupGetter$1 (http://127.0.0.1:8080/sandbox2.dart.js:9126:17)
    at DynamicParserBackend.newAccessScope$1 (http://127.0.0.1:8080/sandbox2.dart.js:7366:21)
    at DynamicParserImpl.parseAccessOrCallScope$0 (http://127.0.0.1:8080/sandbox2.dart.js:7720:29)
    at DynamicParserImpl.parsePrimary$0 (http://127.0.0.1:8080/sandbox2.dart.js:7696:21)
    at DynamicParserImpl.parseAccessOrCallMember$0 (http://127.0.0.1:8080/sandbox2.dart.js:7653:21)
    at DynamicParserImpl.parsePrefix$0 (http://127.0.0.1:8080/sandbox2.dart.js:7649:21)
    at DynamicParserImpl.parseMultiplicative$0 (http://127.0.0.1:8080/sandbox2.dart.js:7628:21)
    at DynamicParserImpl.parseAdditive$0 (http://127.0.0.1:8080/sandbox2.dart.js:7617:21)
    at DynamicParserImpl.parseRelational$0 (http://127.0.0.1:8080/sandbox2.dart.js:7602:21) 

However if I refer the model in the view file, this problem will go away. The following code snippets explain it in slightly more details:

Content of the view:

<!-- this block enables the ctrl.foo reference in the template --
<div ng-repeat="x in ctrl.foo">
    {{ x }}
</div>

<ng-view></ng-view>

Content of the routed template:

<div ng-repeat="x in ctrl.foo">
  {{ x }}
</div>

What version of the product are you using?

angular 0.10.0

On what operating system?

OS X 10.9.4

What browser (if applicable)?

Chrome

Please provide any additional information below.

@ckyang74 ckyang74 changed the title model can't be initiated within ng-view no getter error with ng-view Jul 30, 2014
@ckyang74 ckyang74 changed the title no getter error with ng-view "no getter error" with ng-view Jul 30, 2014
@youssefgh
Copy link

Using Angular.dart v12, i have run to some problems using controllers from parent view, specially if they have the same selector ('ctrl' in my case).
Try adding reference of your controller to the current view.

<div ng-repeat="x in ctrl.foo" my-ctrl>
  {{ x }}
</div>

@vicb
Copy link
Contributor

vicb commented Aug 7, 2014

@ckyang74 The issue is linked to the discussion thread you've mentioned: templates for route are not automatically detected and should be added to your pubspec.yaml:

transformers:
- angular:
    html_files: ['web/view/r2.html']

I'll create an new issue to add the template detection in the transformers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants