标签: angularjs-directive

当值超过 100 时,如何使用 AngularJS 初始化 input[range] 的值

我尝试使用 AngularJS 初始化滑块,但是当值超过 100 时光标显示 100。

在 [50,150] 范围内设置值 150 失败,代码如下:

<html ng-app="App">
<head>
	<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
	<script>
		angular.module('App', ['App.controllers']);
		angular.module('App.controllers', []).controller('AppController', function($scope) {
			$scope.min = 50;
			$scope.max = 150;
			$scope.value = 150;
		});		
	</script>
</head>
<body ng-controller="AppController" >
	{{min}}<input ng-model="value" min="{{min}}" max="{{max}}" type="range" />{{max}}<br/>
	value:{{value}}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

光标放置不当(显示 100 而不是 150)。如何将光标显示到正确的位置?

对发生的事情的解释可以在这个论坛上

更新
此错误报告为问题#6726

更新
问题#14982被拉请求 14996关闭并解决问题,请参阅答案

javascript input range angularjs angularjs-directive

0
推荐指数
1
解决办法
4627
查看次数

为什么浮动权不起作用也使用重要?

我的标题中有三个图像按钮,位于右侧,如图所示,我试图在标题上添加三个按钮。但它没有采用浮动:右侧边距右侧。我需要这样做,请检查图像![在此处输入图像描述][1]

我在右侧有 “+”和搜索和漏斗图像。所以要在右侧制作这个按钮?这是我的plunker

<ion-header-bar align-title="" class="bar-balanced">
  <a class="button button-clear  icon-right ion-chevron-right ">
  </a>

  <h1 class="title">Title!</h1>
  <div style="float:right!important;border:1px solid red ;margin-right:10px">
  <a class="button button-icon icon ion-plus"></a>
  <a class="button button-icon icon ion-search"></a>
  <a class="button button-icon icon ion-funnel"></a>
  </div>

</ion-header-bar>
Run Code Online (Sandbox Code Playgroud)

javascript css angularjs angularjs-directive ionic-framework

0
推荐指数
1
解决办法
626
查看次数

使用 ng-repeat 迭代 hasmap。以数组为值的哈希图

我如何使用 ng-repeat 在 UI 上使用 angularJS 迭代来自服务器的 JSON 响应?

$scope.data = {
  "Home Needs": [{
    "id": 11,
    "itemName": "PARLE G 500 Grams",
    "itemPrice": 50,
    "minSellPrice": 45,
    "discount": 0,
    "store": "Home Needs"
  }],
  "SRI SAI Store": [{
    "id": 1,
    "itemName": "PARLE G 500 Grams",
    "itemPrice": 50,
    "minSellPrice": 45,
    "discount": 0,
    "store": "SRI SAI Store"
  }],
  "Ashirwad": [{
    "id": 10,
    "itemName": "PARLE G 500 Grams",
    "itemPrice": 50,
    "minSellPrice": 46,
    "discount": 0,
    "store": "Ashirwad"
  }]
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我使用 jsfiddle 或指针吗?

谢谢

angularjs angularjs-directive angularjs-scope angularjs-ng-repeat

0
推荐指数
1
解决办法
8946
查看次数

Angularjs 指令将指令添加为属性并动态绑定它们

嗨,我正在处理指令,我需要在其中编辑 DOM 添加 ng-src 属性和模型。

这是我的 DOM

     <edit-component>
      <img src="images/logo.png" title="Hearty Wear" />
    </edit-component>
Run Code Online (Sandbox Code Playgroud)

我需要结果 DOM

       `<div>
         <img src="images/logo.png" title="Hearty Wear" ng-src={{myModel}} />
       </div> `
Run Code Online (Sandbox Code Playgroud)

这样当我用数据更新 myModel 时,图像应该更新

更新

sam.directive('editComponent', function() { return { restrict: 'EA', transclude: true, replace: true, templateUrl: "imageTemplate.html", link: function(scope, element, attb, ctrl, transclude) { scope.data = function() { var imagedata; imagedata = arguments[5]; scope.imageModel = imagedata.base64; return element.find('img').attr('src', "data:image/png;base64," + imagedata.base64); }; } }; });

我还需要先前的src属性值来显示现有图像。

现在我正在手动更新src属性。我需要可以通过模型变量更新的解决方案

谢谢

javascript angularjs angularjs-directive angular-ngmodel angularjs-ng-transclude

0
推荐指数
1
解决办法
3643
查看次数

我怎么能用角度来动态我的flash消息.消息必须通过API响应

我的flash消息代码如下

<div class="flash-message" ng-if="flash">
<div class="{{'alert alert-' + flash.type}}" ng-bind="flash.message"> 
</div>
Run Code Online (Sandbox Code Playgroud)

现在我正在使用

  FlashService.Success('You have blocked this User');
Run Code Online (Sandbox Code Playgroud)

我想让我的上述消息动态,我现在已经通过了静态.

我的节点api现在返回此消息

{
"data": {
    "status": "1",
    "msg": "You have blocked the user"
}
}
Run Code Online (Sandbox Code Playgroud)

node.js npm angularjs angularjs-directive angular-ui-router

0
推荐指数
1
解决办法
83
查看次数

角度动态css类

我有以下情况:

JSON:

[{"id":1,"prio":3},
{"id":2,"prio":3},
{"id":3,"prio":3},
{"id":4,"prio":4},
{"id":5,"prio":2}]
Run Code Online (Sandbox Code Playgroud)

HTML /角

<ul ng-repeat>
<li class="high">{{id}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

现在我的目标是根据属性'prio'自动更改css类.

When prio = 1 --> css= "low"
when prio = 2 --> css = "medium"
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

angularjs angularjs-directive

-1
推荐指数
1
解决办法
58
查看次数

服务不适用于简单的控制器

我有这个js代码

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


app.service('testService', function(){
  this.sayHello= function(text){
    return "Service says \"Hello " + text + "\"";
  };
  this.sayGoodbye = function(text){
    return "Service says \"Goodbye " + text + "\"";
  };
});


app.controller('AboutCtrl', ['testService', function ($scope, $location, $http) {


  $scope.fromService = testService.sayHello("World");
  $scope.toService = testService.sayGoodbye("World");
}]);
Run Code Online (Sandbox Code Playgroud)

在我的HTML中我有这个.... ...嗨{{fromService}} .... ...控制台中没有错误,页面只是空白.

angularjs angularjs-directive angularjs-service angularjs-scope

-1
推荐指数
1
解决办法
1052
查看次数

角度ng重复控制?

我需要重复特定元素一定次数,而不是重复所有元素.

<div ng-repeat='el in elements'>
    <div>{{el.someValue}}</div>//repeat here only 3 times 
    <div>{{el.someValue}}</div>// repeat here only 2times something like this
</div>
Run Code Online (Sandbox Code Playgroud)

我可以这样做吗?

angularjs angularjs-directive angularjs-scope angularjs-ng-repeat

-2
推荐指数
1
解决办法
119
查看次数

为什么AngularJS在定义时会在指令中显示范围变量未定义?

我有一个angularJS指令,通过以下方式调用:

<rpt-closing closing-begin-ts="null" closing-begin-ts="'2014-11-25 23:59:59'"></rpt-closing>
Run Code Online (Sandbox Code Playgroud)

指令代码如下:

  .directive('rptClosing',function(){
      return {
        restrict:'E',
        scope: {
          closingBeginTs: '=',
          closingEndTs: '='
        },
        link: function(scope, element, attrs) {
          console.log('*******************************************');
          console.log('scope = ', scope);
          console.log('scope.closingBeginTs = ', scope.closingBeginTs);
          console.log('scope.closingEndTs = ', scope.closingEndTs);
          console.log('*******************************************');
        },
        template: '<div>BLAH BLAH BLAH</div>'
      };
    }
  )
Run Code Online (Sandbox Code Playgroud)

这段代码在jsFiddle中运行得非常好.我能看到的价值scope.closingBeginTs,并scope.closingEndTs在控制台输出.

在此输入图像描述

javascript angularjs angularjs-directive angularjs-scope

-2
推荐指数
1
解决办法
198
查看次数