0

Im new with this language and this framework, Ive made a command-line app and it works perfectly and now I wanna make a very simple web interface

I have this in my .html

<body ng-app>
.
.
.
<input type="submit" ng-click="doSomething()">

In my .dart

import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
.
.
.
void doSomething(){
lotToDo;
}

And I get this

Property 'doSomething' is not of type function.

Whats the point of the error ? Its necesary to use a controller ?

Thanks to all !

1 Answer 1

1

You need a controller that contains the doSomething() method.

See https://github.com/angular/angular.dart.tutorial/blob/master/Chapter_03/lib/recipe_book.dart for example.

The index.html has a tag <body recipe-book> tag. Angular applies the controller declared in recipe_book.dart here because this controller has the selector selector: '[recipe-book]' assigned which is a tag that has the attribute recipe-book.

You also need to initialize a module so Angular knows of this controller.

library recipe_book;

import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';

import 'package:angular_dart_demo/rating/rating_component.dart';
import 'package:angular_dart_demo/recipe_book.dart';

class MyAppModule extends Module {
  MyAppModule() {
    type(RecipeBookController); // register controller in a module
    type(RatingComponent);      // register some other component
  }
}

void main() {
  applicationFactory()
      .addModule(new MyAppModule()) // tell angular to use the modul declared above
      .run();
}

My advice: work through this tutorial before trying random things https://angulardart.org/tutorial/

Sign up to request clarification or add additional context in comments.

2 Comments

With controllers works perfectly but i was looking for something simple. I just need to get used to this language. Thanks so much for your help
I think this is as simple as it gets with Angular.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.