--prod strange behaviour with ng-reflect - cli 3.13.2


#1

I am facing a very strange behavior with building with --prod, I am using the latest Ionic cli 3.13.2

I appreciate if anyone can tell me how to solve the problem or change my code to achieve the desired outcome in the last code block below.

I have a list of checkboxes

<ion-list>
    <ion-item *ngFor="let user of people.items">
      <ion-label>{{user.name}}</ion-label>
      <ion-checkbox [value]="user.id"></ion-checkbox>
    </ion-item>

When I run/build with --debug or even with --prod --livereload, the code comes out correctly as below

<ion-checkbox class="checkbox checkbox-md" tappable="" ng-reflect-value="1">
  <div class="checkbox-icon">
    <div class="checkbox-inner"></div>
......
......
</ion-checkbox>

When I run/build with --prod only, the ng-reflect-value=“1” in the ion-checkbox tag (first line) disappears! and comes out as follows

<ion-checkbox class="checkbox checkbox-md" tappable="">
  <div class="checkbox-icon">
    <div class="checkbox-inner"></div>
.....
.....
</ion-checkbox>

The real problem is that I use this value later on to get the ids of the checked boxes as below

let checkedBoxes = this.el.nativeElement.querySelectorAll('.checkbox-checked');
    if (checkedBoxes.length > 0) {
      [].forEach.call(checkedBoxes, function(box) {
        selected.push(parseInt(box.parentNode.getAttribute('ng-reflect-value')));
      });

#2

What is your ionic info output?


#3

cli packages: (/home/oem/.nvm/versions/node/v6.9.5/lib/node_modules)

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.2

global packages:

cordova (Cordova CLI) : 6.5.0 

local packages:

@ionic/app-scripts : 1.1.4
Cordova Platforms  : android 6.1.2 ios 4.3.1
Ionic Framework    : ionic-angular 2.2.0

System:

Android SDK Tools : 26.1.1
Node              : v6.9.5
npm               : 2.15.12 
OS                : Linux 4.10

Misc:

backend : pro

#4

Just to clarify, upgrading to ionic-angular 3 introduced a huge number of UI changes/problems, I had to go back to 2.2.0 for now.


#5

No reason not to upgrade these - these are relevant for the build process.


#6

I am afraid they would introduce unforeseen problems like the one in this very post. I finally got the App into a stable state after a few months of struggling. I am also not 100% sure this would actually solve the problem. Is there any way around this without this upgrade? I want to ship this release out and then deal with all the upgrades to come to the latest version.


#7

No idea, but I am not willing to debug broken code. That’s why new versions are released, to fix known bugs and problems.
You will have to find someone else to help you.


#8

I totally understand. Is there maybe any other way to achieve the desired? Different html code, different ts code?