This is an example of vue UI components wrapped to use as generic UI component.
Thanks to vue is possible to use vue components in all ecosystems; react, angular, svelte...
See the examples folder for more details.
It's just a demonstration library how is possible to implement reusable components in all ecosystems via Vue.js library.
It could be a good alternative to wrap vue components in a web component.
src/components
<div ng-app="app">
<div ng-controller="ParentController as parent">
<h1>Vue component:</h1>
<wv-todo-list id="embed-list" @item-added="listenInput"></wv-todo-list>
<h1>Angular app:</h1>
{{ somePrimitive }}
</div>
</div>
<script>
function ParentController($scope) {
$scope.somePrimitive = "Hi from Angular";
$scope.updateValues = function(newItem) {
$scope.$applyAsync(function() {
$scope.somePrimitive = 'Listen Vue event from Angular, new item added: ' + newItem;
});
};
const vueComponentMethod = {
listenInput: $scope.updateValues.bind($scope)
};
window.vComponents.embed(document.querySelector("#embed-list"),undefined, vueComponentMethod);
}
angular.module('app', []).controller('ParentController', ParentController);
const app = angular.module('myApp', []);
</script>
<!-- define template: -->
<template id="todo-list">
<span>Write a text:</span>
<input type="text" v-model="input">
<h1>{{input}}</h1>
</template>
<!-- use it: -->
<wv-todo-list id="embed-list"></wv-todo-list>
<script>
window.params = {
input: ""
};
window.vComponents.define(document.querySelector("#todo-list"));
window.instance = window.vComponents.embed(document.querySelector("#embed-list"), window.params);
</script>