Code Monkey home page Code Monkey logo

Comments (5)

bcherny avatar bcherny commented on May 28, 2024

Hi @frankandrobot! Unfortunately from your description it's not clear to me what's causing this. If you could post a self contained repro case in something like StackBlitz that would be really helpful.

from react2angular.

frankandrobot avatar frankandrobot commented on May 28, 2024

Sorry I'm using an old Angular 1.5.8... just took a look at stackblitz and it comes preconfigured with the latest Angular. And I don't believe you have a version of react2angular that can be loaded in a script tag (so no to js fiddle).

The example is very easy to repo.

  • Initialize the redux state
  • Create an AJAX request in the component $onInit that updates the redux state
  • Use the redux state to control the value of ng-disabled.

from react2angular.

bcherny avatar bcherny commented on May 28, 2024

@frankandrobot I want to help get to the root of this issue, and I need a full repro case to get there. If Stackblitz doesn't work for you, could you attach a minimal repro case in a zip file?

from react2angular.

frankandrobot avatar frankandrobot commented on May 28, 2024

OMG, what the fuck? It looks like this is some wierd Angular issue (why am I not surprised). Here is the minimal HTML template. Notice how I have two inputs behind an ng-if. If I change ng-if to ng-show, all sorts of wierdness happens:

  1. The form never validates (and as a result, the submit never is never enabled)
  2. The email thinks it's invalid on start (which is what started this issue in the first place).

Gonna test now with both inputs showing (which is actually hard to do in my code base---because getting the database in that state is tricky). And see if everything is well.

            <form role="form" name="$ctrl.angularState.form" ng-submit="$ctrl.update()">
              <div ng-if="$ctrl.missing.username"
                   class="form-group textInputContainer"
                   ng-class="{ 'hasError' : $ctrl.angularState.form.username.$invalid && !$ctrl.angularState.form.username.$pristine }"
              >
                <label for="username">Username</label>
                <input type="text"
                       class="form-control"
                       name="username"
                       ng-model="$ctrl.user.username"
                       valid-username
                       not-blank='{"disabled": {{!!$ctrl.readonly.username}}}'
                       ng-disabled="!!$ctrl.readonly.username"
                       autofocus
                />
              </div>
              <div ng-if="$ctrl.missing.email"
                   class="form-group textInputContainer"
                   ng-class="{ 'hasError' : $ctrl.angularState.form.email.$invalid && !$ctrl.angularState.form.email.$pristine }"
              >
                <label for="email">Email</label>
                <input type="text"
                       class="form-control"
                       name="email"
                       ng-model="$ctrl.user.email"
                       valid-email='{"disabled": {{!!$ctrl.readonly.email}}}'
                       not-blank='{"disabled": {{!!$ctrl.readonly.email}}}'
                       ng-disabled='!!$ctrl.readonly.email'
                />
              <input type="submit"
                     class="btn"
                     ng-class="{disabled: $ctrl.saving || !$ctrl.angularState.form.$valid, 'btn-primary': !$ctrl.saving && $ctrl.angularState.form.$valid}"
                     ng-disabled="$ctrl.saving || !$ctrl.angularState.form.$valid"
                     value="Save"
              />
            </form>

from react2angular.

frankandrobot avatar frankandrobot commented on May 28, 2024

Update this works just fine now. Gonna write this off as another one of those "angular quirks"

from react2angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.