Consider below code, the condition ko if: falg
does not work. How to define variable falg = "false"
in this file?
<!-- ko falg = "false" --> <!-- /ko -->
<!-- ko if: product_has_url -->
<!-- ko falg = "true" --> <!-- /ko -->
<!-- /ko -->
<!-- ko if: falg -->
...
<!-- /ko -->
update: I'm writing module to customize the minicart content. Below is the structure:
registration.php
|
+---etc
| | module.xml
| |
| \---frontend
| di.xml
|
+---Plugin
| DefaultItem.php
|
\---view
+---frontend
\---layout
| checkout_cart_sidebar_item_renderers.xml
|
\---web
\---js
\---myscript.js
\---template
\---minicart
\---item
default.html
\---requirejs-config.js
So now my challenge is to pass the flag
from myscript.js
to based on the item attibute product_has_url
to default.html
myscript.js ?
define([
'uiComponent',
'Magento_Customer/js/customer-data',
'jquery',
'ko',
'sidebar'
], function (Component, customerData, $, ko) {
function checkAttr() {
}
return Component.extend({
});
});
Best Answer
You can try this :
In js file you can use like this :
After this you need to deploy static content or to test you can add changes directly in the same
js
andhtml
file ofpub/static
.