0

I'm working on an application that's built with Dart and Angular2. I'm using an external JS library that takes a simple HTML template (not an Angular template) in the form of a string. Right now I'm just storing the template inline in the Dart file, but that's a little messy. Is there a way I could put the template in a separate file?

1 Answer 1

1

You can create a file with the content like

const String someString = '''
here goes the template content
''';

and then import that file and pass someString around.

You can also safe the template content in a non-Dart file and request it from the server.

There is also the https://pub.dartlang.org/packages/resource package to load resource files.

1
  • 1
    Just using constants in a separate file seems like the simplest solution, I'll stick to that for now. Feb 25, 2016 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.