Pergunta

I just migrated to angular-0.10.0. My application works as expected in Dartium but in js through dart2js I get the follow unminified error in web console :

No getter for 'ctrl'.

STACKTRACE:
Error
    at dart.wrapException (http://localhost:8080/app/main.dart.js:2390:15)
    at StaticClosureMap.lookupGetter$1 (http://localhost:8080/app/main.dart.js:8926:17)
    at DynamicParserBackend.newAccessScope$1 (http://localhost:8080/app/main.dart.js:7177:21)
    at DynamicParserImpl.parseAccessOrCallScope$0 (http://localhost:8080/app/main.dart.js:7531:29)
    at DynamicParserImpl.parsePrimary$0 (http://localhost:8080/app/main.dart.js:7507:21)
    at DynamicParserImpl.parseAccessOrCallMember$0 (http://localhost:8080/app/main.dart.js:7464:21)
    at DynamicParserImpl.parsePrefix$0 (http://localhost:8080/app/main.dart.js:7460:21)
    at DynamicParserImpl.parseMultiplicative$0 (http://localhost:8080/app/main.dart.js:7439:21)
    at DynamicParserImpl.parseAdditive$0 (http://localhost:8080/app/main.dart.js:7428:21)
    at DynamicParserImpl.parseRelational$0 (http://localhost:8080/app/main.dart.js:7413:21) 

The pubspec.yaml

name: app
version: 0.0.1-dev
dependencies:
  angular: any
  browser: any
dev_dependencies:
  unittest: any
transformers:
- angular

The controller :

@Controller(selector: '[myCtrl]', publishAs: 'ctrl')
class MyController {
  String search = 'test';
}

The html template :

<div myCtrl>
  <input ng-model="ctrl.search"></input>
  {{ ctrl.search }}
</div>

The error only appear inside an <ng-view>. If I add the above html directly in the main html the js error does not appear.

Foi útil?

Solução

Pavel Jbanov indicates in this post :

I believe expression_generator transformer is unable to discover your template file, so you might need to manually include it: https://github.com/angular/angular.dart/blob/master/lib/tools/transformer/options.dart#L17

and further :

The transformer will hopefully get better at identifying template files so you don't have to manually list them. Right now, afaik, it only picks up template files of components.

So for now you have to manually add all untracked html templates inside your pubspec.yaml like this in the html_files section :

name: app
version: 0.0.1-dev
dependencies:
  angular: any
  browser: any
dev_dependencies:
  unittest: any
transformers:
- angular:
    html_files:
    - web/template1.html
    - web/template2.html
    - web/template3.html
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top