Slot.js
628 Bytes
class Slot {
useModules = ["$compile"];
componentDidUpdate(prevProps) {
if(prevProps.content !== this.props.content) {
if (newVal !== undefined) {
if (/<[^>]+>/.test(newVal)) {
$element.replaceWith(
$compile(newVal)(
$scope.context ? $scope.context : $scope
)
);
} else {
$element.text(newVal);
}
}
}
}
}
Slot.propTypes = {
content: PropTypes.string,
context: PropTypes.object,
};