简体   繁体   中英

Polymer.dart propertyNameChanged method in a custom library isn't working

This is my polymer.dart class.

import 'package:polymer/polymer.dart';

/**
 * A Polymer x-changer element.
 */
@CustomTag('x-changer')

class XChanger extends PolymerElement {

  @published String prop;

  propChanged() {
    print("prop changed!");
  }

  /// Constructor used to create instance of XChanger.
  XChanger.created() : super.created() {
  }


}

This is my project structure:

  • example
    • chat_example
    • lib
    • web
  • lib
    • x-changer.dart
    • x-changer.html
  • test

When I add x-changer.dart & x-changer.html in my example folder it works. It is exactly the same code, am I missing something that is important for a polymer element library?

EDIT: This is the library pubspec

name: some_elements
description: >
  The polymer elements for ...
version: 0.0.1
author: Joris Hermans
#homepage: https://www.example.com
dependencies:
  polymer: '>=0.15.4 <0.16.0'
dev_dependencies:
  unittest: any

You need to add the polymer transformer in the library (without entry_points).

You shouldn't import like You shouldn't import like `

It should look more like

You shouldn't import like <link rel="import" href="packages/chat_example/force/force_client_element.html">

You might need one or more additional ../ prefixes, depending on where the importing file resides (this is never necessary in Dart package:xxx imports.

<link rel="import" href="../packages/chat_example/force/force_client_element.html">

See https://www.dartlang.org/polymer/app-directories.html for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM