首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >火狐的日期验证、Input[date]和AngularJS数据报警器

火狐的日期验证、Input[date]和AngularJS数据报警器
EN

Stack Overflow用户
提问于 2014-11-17 11:17:30
回答 1查看 1.1K关注 0票数 0

我对Firefox有一个可比较性的问题。我已经有一个工作的角度应用程序生产,但日期输入只在Chrome上工作。我忽略了这一点,现在当它在Firefox和IE中运行时,我有一个坏了的应用程序。

我不想检查AngularJS-Bootstrap数据收集路由,因为:

  1. 我已经有了一个结构化的应用程序,它正在webkit浏览器上工作。
  2. 我的应用程序是一个独立的AngularJS (独立的)从我的启动-指南针在一个应用程序。
  3. 我没有使用角度引导,因为我不知道有存在。
  4. 我只有一个小难题,那就是输入,这仅仅是一个与其他浏览器兼容的HTML5问题。
  5. 因为这只是一个小问题,我不想为它做一个重大的解决办法。
  6. 我只有有限的时间来解决这个问题,所以我必须尽快解决它。

以下是我迄今所做的工作:

  1. 我尝试了,但是它依赖于版本1.2,我运行的是AngularJS 1.3。
  2. 让它在Firefox上工作的指令看起来太过调整了,或者至少它没有详细的信息去做。
  3. 我目前正在尝试使用jQuery UI的数据报警器,但由于某种原因,它在应用程序中无法工作(虽然它在应用程序之外工作)。

这是我的密码:

代码语言:javascript
复制
<input type="text" id="bdate" name="bdate" ng-class="{'has-error': $submitted && signup.bdate.$invalid}" ng-model="formData.bdate" required class="form-control" placeholder="Birthday mm/dd/yyyy">

它具有如下的验证:

代码语言:javascript
复制
<li ng-show="signup.bdate.$error.date"><p>Please enter a valid birth date.</p></li>

这是我的app.js:

代码语言:javascript
复制
var spinnrApp = angular.module('spinnrApp', ['ngAnimate', 'ui.router', 'slick', 'ngMessages']);

spinnrApp.config(function ($stateProvider, $urlRouterProvider) {
  //
  // Now set up the states
  $stateProvider
    .state('registration', {
      url: "/registration",
      templateUrl: "app/components/registration/registration.php",
      controller: "FormController"
    })
    .state('registration.spinnrapp', { // nested state for the registration form
      url: "/spinnrapp", // url will be nested /registration/artist
      templateUrl: "app/components/registration/partials/registration-profile.php"
    })
    .state('registration.artist', { // nested state for the registration form
      url: "/artist", // url will be nested /registration/artist
      templateUrl: "app/components/registration/partials/registration-artist.php"
    })
    .state('registration.share', { // each nested state will have their own view
      url: "/share", // url will be nested /registration/share
      templateUrl: "app/components/registration/partials/registration-share.php"
    });
    //
    // For any unmatched url, redirect to /
    $urlRouterProvider.otherwise("/registration/spinnrapp");
});

spinnrApp.controller('FormController', ['$scope', '$http', '$state', function (scope, http, state){

  // get list of cities and store it to select
  http.get('cities.json').success(function(data){
    scope.cities = data;
  })

  // we will store all our form data in this object
  scope.formData = {};

  // function to process the form
  scope.processForm = function(isValid) {
    scope.$submitted = true;
    if(isValid && state.$current=='registration.spinnrapp') {
      state.go('registration.artist');
    } else if(isValid && state.$current=='registration.artist') {
      state.go('registration.share');
    } else if(!isValid && state.$current=='registration.artist') {
      alert('Please make sure you have selected an artist.');
    }
  };
}]);

以下是我的主要问题:

  1. 如果我要使用指令,如何根据当前的结构来实现呢?
  2. 为什么jQuery数据报警器在其角度应用程序中无法运行,而当我将它作为静态DOM元素处理时运行得很完美呢?
  3. 这里有一个简单的方法吗?这样我就不用进行大量的代码调整了吗?

最后,以下是我的所有脚本,以防您想知道我是如何将这些(index.php)组合在一起的:

代码语言:javascript
复制
<script src="app/angular/jquery/dist/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/bootstrap/tab.js"></script>
<script src="app/angular/angular/angular.min.js"></script>
<script src="app/angular/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="https://code.angularjs.org/1.3.0/angular-animate.min.js"></script>
<script src="https://code.angularjs.org/1.3.0/angular-resource.min.js"></script>
<script src="app/angular/angular-messages/angular-messages.min.js"></script>
<script src="app/angular/slick-carousel/slick/slick.min.js"></script>
<script src="app/angular/angular-slick/dist/slick.min.js"></script>
<script src="app/app.js"></script>
<script>
  $(document).ready(function() {
    $("#bdate").datepicker();
    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
      var target = this.href.split('#');
      $('.nav a').filter('[href="#'+target[1]+'"]').tab('show');
    });
  });
</script>
EN

回答 1

Stack Overflow用户

发布于 2014-11-17 11:34:43

您的输入id是"bdate“将$(”#datepicker“).datepicker()更改为$("#bdate").datepicker();

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26971518

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档