Created
June 8, 2023 07:24
-
-
Save ozknozsrt/7b9abd43f40fed591fc98bf63c048bb4 to your computer and use it in GitHub Desktop.
knockout js ko component example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wwwroot/js/ui-components klasörü açıp içinde her component'e özel dosyalar olabilir: | |
// alert-message.js | |
ko.components.register('alert-message', { | |
viewModel: function (params) { | |
var self = this; | |
self.css = params.css; | |
self.icon = params.icon; | |
self.text = params.text; | |
self.title = translate(`global.${self.icon}`); | |
}, | |
template: `<div class="cs-alertbox" data-bind="css: css"> | |
<i class="material-icons" data-bind="text: icon"></i> | |
<!-- ko if: title.length > 0 --> | |
<h4 data-bind="text: title"></h4> | |
<!-- /ko --> | |
<p data-bind="text: text"></p> | |
</div>` | |
}); | |
// html üzerindeki kullanım şekli: | |
<alert-message params="css: 'cs-alertbox--warning-darker', icon: 'warning', text: translate('pages.graph.negativeValuesNotSupported')"></alert-message> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment