GVKun编程网logo

angularjs – 快速离开并输入导致角度ng-if动画中的多个元素(angular跳转)

21

本文的目的是介绍angularjs–快速离开并输入导致角度ng-if动画中的多个元素的详细情况,特别关注angular跳转的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的

本文的目的是介绍angularjs – 快速离开并输入导致角度ng-if动画中的多个元素的详细情况,特别关注angular跳转的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解angularjs – 快速离开并输入导致角度ng-if动画中的多个元素的机会,同时也不会遗漏关于angularjs – Angular 1.2不再允许在同一个元素上使用多个隔离的范围指令?、angularjs – Angular Js:如何在ng-repeat中找到第一个和最后一个元素,并向他们添加特殊类?、angularjs – Angular ui路由器具有路由(状态)参数的多个视图、angularjs – angular.bootstrap运行多个角度应用程序的知识。

本文目录一览:

angularjs – 快速离开并输入导致角度ng-if动画中的多个元素(angular跳转)

angularjs – 快速离开并输入导致角度ng-if动画中的多个元素(angular跳转)

此文档中有一个ng-if动画示例: https://docs.angularjs.org/api/ng/directive/ngIf
如果您快速反复点击复选框,您会发现不止一个元素将被显示,我不知道如何避免它。
这是因为ngIf与ngShow的行为不同,例如。 ngShow只需要为必须隐藏的元素添加一个display:none样式,而ngIf则执行以下操作:

The ngIf directive removes or recreates a portion of the DOM tree
based on an {expression}. If the expression assigned to ngIf evaluates
to a false value then the element is removed from the DOM,otherwise a
clone of the element is reinserted into the DOM.

所以如果动画需要很长时间,那么DOM中就会有不止一个元素。

在Olivvv的例子中,如果你只是将.animate-if.ng-enter的延迟更改为.animate-if.ng,那么你将不会得到多于一个元素。

在这里可以看到它是官方AngularJS文档的分叉版本。 http://plnkr.co/edit/ok7nwOIRpR1TYYRkBRXj?p=preview

我只将其延迟从0.5s修改为0.001s

angularjs – Angular 1.2不再允许在同一个元素上使用多个隔离的范围指令?

angularjs – Angular 1.2不再允许在同一个元素上使用多个隔离的范围指令?

我在Angular项目中有一些代码,它们使用两个具有隔离范围的独立指令.它们不需要共享范围,只需存在于同一元素上.它们都以稍微不同的方式改变DOM,并且重要的是绑定到作为参数传递的值.

这在1.0中工作,但是Angular 1.2现在在尝试执行此操作时会生成错误

Multiple directives asking for new/isolated scope

基于项目git历史出现Angular 1.2更改行为,以保持两个隔离的指令在同一元素上分开.这是一件好事,当在同一元素上放置两个“Attribute”指令时,它可以正常工作.

<div my:directive="myDirectiveData" my:other-directive="myOtherDirectiveData" />

像你期望的那样工作.

然而

<my:directive my:directive-data="myDirectiveData" my:other-directive="myOtherDirectiveData" />

引发上述错误. (多个指令要求新/隔离范围)

在这种情况下,我希望每个指令仍然与它们自己的非共享隔离范围并行存在.

这在Angular 1.2中仍然可行吗?

在同一元素上定义多个指令时会发生什么情况的摘要:
  Scenario  directive #1   directive #2   Result
     1      no new scope   no new scope   Both directives use the controller's scope.
                                          (This should be obvIoUs.)
     2      new scope      new scope      Both directives share one new child scope.
     3      new scope      no new scope   Both directives share one new child scope.
                                          Why does dir #2 use the child scope?
                                          This seems odd to me.
     4      isolate scope  no new scope   Angular v1.0: both directives share the
                                          isolate scope.
                                          Angular v1.2+: dir #1 uses the isolate scope,dir #2 uses the controller's scope.

请注意,不允许以下方案(Angular引发错误):

  Scenario  directive #1   directive #2
     5      isolate scope  new scope
     6      isolate scope  isolate scope

angularjs – Angular Js:如何在ng-repeat中找到第一个和最后一个元素,并向他们添加特殊类?

angularjs – Angular Js:如何在ng-repeat中找到第一个和最后一个元素,并向他们添加特殊类?

我改变了以下使用角度js
<section id="social">
    <h2>Social Profiles</h2>
    <a href="#"https://www.jb51.cc/tag/irs/" target="_blank">irst"><i></i></a>
    <a href="#"><i></i></a>
    <a href="#"><i></i></a>
    <a href="#"><i></i></a>
    <a href="#"><ihttps://www.jb51.cc/tag/RSS/" target="_blank">RSS"></i></a>
    <div></div>
</section>

对此

<section id="social">
    <h2>Social Profiles</h2>
    <a ng-repeat="sMedia in socialMedia" ng-if="$first" href="#" >
        <i></i>
    </a>
    <div></div>
</section>

一切似乎都很好,除非我找不到一种方法,在ng-repeat的最后一个元素中的第一个元素和class =“last”中添加class =“first”。

只需使用$ first和$ last结合ng-class:
<a ng-repeat="sMedia in socialMedia" ng-https://www.jb51.cc/tag/irs/" target="_blank">irst': $first,'last': $last}" href="#" >

看到他们如何工作:https://docs.angularjs.org/api/ng/directive/ngRepeat

angularjs – Angular ui路由器具有路由(状态)参数的多个视图

angularjs – Angular ui路由器具有路由(状态)参数的多个视图

我有一个页面,我显示两个不同的产品列表使用多个视图,每个具有控制器和模板文件.我的状态定义如下:
.state('all_lists',{
      url: '/lists',views: {
      '' : {templateUrl: 'my-lists.html'},'featured@all_lists' : {templateUrl: 'featured.html',controller: 'featuredCtrl'},'deals@all_lists' : {templateUrl: 'deals.html',controller: 'dealsCtrl'}
      }
     }
    )

每个单独的列表都有顶部的分页和排序过滤器,这些分页和排序过滤器作为状态参数添加到URL中.
请告诉我如何为状态的视图定义这些参数,以便将它们添加到URL中,然后在相应的控制器中使用.

如果您更好地了解如何将分页参数添加到URL中的产品列表,请分享您的想法.
任何帮助将不胜感激.

谢谢

注意:
请注意,我需要在1页上显示这两个列表.它的一种主页和特色项目列表,然后下面的热交易项目列表显示,这两个列表都有分页,排序和其他几个过滤器.
URL将是这样的.
mydomain.com/products/featured-page_1/deals-page_2/perpage_10/

笔记2:
经过深入研究和调查,我发现这是平行国家的一个明显的例子.请告诉我如何使用我目前使用的URL参数方案来实现并行状态.

<html>
  <head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
    </head>
  <body>
    <div id="content">
      <h1>Products Homepage</h1>
      <h3>Some common filters for both lists</h3>
    <div id="featured">
      <h2>Featured List</h2>
      <div>pagination and other filters</div>
      <ul>
        <li>item 1</li>
        <li>item 2</li>
        <li>item 3</li>
        <li>item 4</li>
        <li>item 5</li>
      </ul>
      </div>
      <div id="deals">
        <h2>Hot Deals List</h2>
      <div>pagination and other filters for hot deals</div>
      <ul>
        <li>item 1</li>
        <li>item 2</li>
        <li>item 3</li>
        <li>item 4</li>
        <li>item 5</li>
      </ul>
      </div>
    </div>
    </body>
  </html>
将它们视为多重视图,而不是将其视为父级抽象的子视图.看下面的代码,
$stateProvider
    .state("product",{
        url: '/product',templateUrl: "/Views/productHome.html",abstract: true,controller: "productHomeCtrl"
    })
    .state('product.thumbnailview',{
        url: '/producttv',templateUrl: "/Views/thumbnailview.html",controller: "thumbnailViewCtrl",params: {
            param1: null,param2: null
        }
    })
    .state('product.listview',{
        url: '/productlv',templateUrl: "Views/listview",controller: "listViewCtrl",param2: null
        }
    })

现在您可以通过在相应的控制器中分别注入stateParams服务来使用参数.
注意:
另外你的产品状态根本不会有stateParam.

注意:但如果您尝试直接到达产品状态,它将不会被激活,因为它是抽象状态
如何通过在productHome.html或全局或相应视图中获取标记来处理分页.

如果您在productHome.html中保留分页,您仍然可以使用$scope.$parent.productList访问productDetails数组,并重用相同的作用域变量.

所以在这种情况下,你的productHome.html将会这样

<div> 
    <div > MENU OPTIONS </div>
    <div ng-view>   </div>
    <ul uib-pagination total-items="itemLength" ng-model="currentPage" ng-change="pageChanged()"></ul>
</div>

这三个对象可以在三个控制器中的任意一个处理

> itemLength
> currentPage
> pageChanged()

缩略图和列表视图都将包含仅用于布局目的的标记.

<div>
    <div> Thumbnail or List markup </div> very simple you can play with bootstrap grid layout.
</div

更新1

对于这样的路线

//mydomain.com/products/featured-page_1/deals-age_2/perpage‌​_10/

使用我的解决方案,你可以处理这样的事情

//mydomain.com/products/featured/page_1/deals/age_2/

所以你的孩子将会是

$stateProvider
    .state("product",controller: "productHomeCtrl"
    })
    .state('product.featured/',{
        url: '/featured/:number',templateUrl: "/Views/featured.html",controller: "featuredCtrl",params: {
            number: null,}
    })
    .state('product.deals',{
        url: '/deals/:number',templateUrl: "Views/deals.html",controller: "dealsCtrl",params: {
            number: null
        }
})

在featuresCtrl中,您可以使用这些参数访问这些参数

$stateParam.number

在DealsCtrl中,您可以使用这些参数访问这些参数

$stateParam.number

在$rootscope中或在productHomeCtrl中保留该值

angularjs – angular.bootstrap运行多个角度应用程序

angularjs – angular.bootstrap运行多个角度应用程序

这不是Twitter Bootstrap问题……

我有一个用例需要加载单独的角度应用程序.

根据几个堆栈溢出问题和this google thread,它是可行的.但是,我无法让它发挥作用.

看文档:

http://docs.angularjs.org/api/angular.bootstrap

看起来你需要提供元素(如何获取元素的句柄?),然后如何将它与配置,控制器等联系起来.这对路由有何影响?似乎一个应用程序使用否则另一个使用否则,第二个将覆盖第一个?

谢谢!

要获取对您的应用程序的引用,您可以执行以下操作:
var first = document.getElementById('firstapp-id');
var second = document.getElementById('secondapp-id');

angular.bootstrap(angular.element(first),['firstapp']);
angular.bootstrap(angular.element(second),['secondapp']);

其中’firstapp’和’secondapp’是模块/应用程序名称,’firstapp-id’和’secondapp-id’是每个应用程序(或您最喜欢的DOM元素)的容器div的id.只需以通常的方式定义您的应用:

var firstapp = angular.module('firstapp',[]);
var secondapp = angular.module('secondapp',[]);

关于angularjs – 快速离开并输入导致角度ng-if动画中的多个元素angular跳转的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于angularjs – Angular 1.2不再允许在同一个元素上使用多个隔离的范围指令?、angularjs – Angular Js:如何在ng-repeat中找到第一个和最后一个元素,并向他们添加特殊类?、angularjs – Angular ui路由器具有路由(状态)参数的多个视图、angularjs – angular.bootstrap运行多个角度应用程序的相关信息,请在本站寻找。

本文标签: