ng-style

Kendo UI Grid and ng-style

点点圈 提交于 2019-12-12 05:58:55
问题 I have a Kendo UI Grid in angular which is reading from my datasource a series of properties. One of them contains a color string. I want to use said color string to set the background-color for a square-box in the grid. I'm using the following template for the box: template: "<img class='alarm-box-prediction variable' ng-style={'background-color': dataItem.type}'></img>" The relevant data from my dataSource is the following: dataSource: { dataSource: function(data) { // Map the stored

AngularJS - Conditionally apply style using ng-style to first element in ng-repeat

坚强是说给别人听的谎言 提交于 2019-12-11 09:27:13
问题 I have an object of styles and I need to set another css style only for the first element. I created a directive especially for that, but it doesn't work I will appreciate your help! Here is the code: <div class="row" ng-style="rowCss" ng-repeat="top in gridObj" ng-zero> $scope.rowCss = { "height" : rowAndSquareHeight, "padding-top": baseLine } editorApp.directive('ngZero', ['$document', '$parse', function($document, $parse) { return function(scope, element, attr) { $(element).css({"padding

Angular 2/4, “ngStyle”. Apply different style depeding its father element active o inactive

穿精又带淫゛_ 提交于 2019-12-11 05:32:40
问题 I need to apply a style to an element when it parent element is actived. I'm using routerLinkActive to apply CSS Class and works fine, but deppending if the father element is actite apply one inline style (display: block), in other cases apply another (display: none). If parent element is active: <li class="active"> <ul class="sub-menu" style="display: block;"> </li> <li> <ul class="sub-menu" style="display: none;"> </li> When I choose another element: <li> <ul class="sub-menu" style="display

How to get multi css rule for ng-style by function?

房东的猫 提交于 2019-12-08 15:02:13
问题 I need for apply multi css rule to html tag in angular form template. <div class="form-control" id="data.objectStyle" ng-model="data.type" ng-style="getStyle(data.objectStyle)"> {{data.objectStyle.title}} </div> getStyle function in controller : $scope.getStyle = function (taskType) { return { background-color:taskType.backColor, color: taskType.color, font-size:taskType.fontSize, font-family:taskType.font } )}; taskType object: { backColor:'#006', color:'#56DA', fontSize:12, font:'New Times

Angular - How to apply [ngStyle] conditions

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 10:39:22
I have a div that I want to style based on a condition. If styleOne is true I want a background colour of red. If StyleTwo is true, I want the background colour to be blue. I've got half of it working with the below code. <div id="myDiv" [ngStyle]="styleOne && {'background-color': 'red'}"> Is it possible to add a condition to say: if styleOne is true, do this if styleTwo is true, do this? Edit I think i've resolved it. It works. Not sure if it's the best way: <div id="div" [ngStyle]="styleOne && {'background-color': 'red'} || styleTwo && {'background-color': 'blue'}"> For a single style

Angular ng-style background image when url contain spaces

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to apply a background image to a div by using the angular ng-style and it works fine as long as the URL does not contain spaces. ng-style="{'background-image': 'url(' + parentIMGLink + ')'}" When there is space in URL like parentIMGLink = servername.images/there is name.png it does not work. On the other hand: img ng-src={{parentIMGLink }} Works fine. For sure I can manage so that names on the server wont contain spaces but is there any possibility to make ng-style work? 回答1: Just like in css you have to wrap your the image url in

Convert number to degrees in ngStyle using Angular 8

南笙酒味 提交于 2019-12-03 00:49:45
问题 {{result.percentage}} gives me a number from 0 to 100. If I get 25, I want it to convert to -45 degrees or if I get 0, I want it to convert to -90 degrees or if I get 75, then it gets converted to 45 degrees. [ngStyle]="{'transform': 'rotate(' + result.percentage + 'deg)'}" Current, this gives an output style="transform: rotate(25deg);" which I want to convert to style="transform: rotate(-45deg);" How do I go about this? FYI, I need to bind the data of this speedometer: https://jsfiddle.net

How to progress bar with ng-style

我与影子孤独终老i 提交于 2019-12-02 11:10:54
问题 I am trying to make a progress bar with ng-style. The problem is that, when I make it, the progress slider goes only by middle, and does not cover the whole bar. The progress bar should be in hours, like: 4h, 5h etc. When I make it with %, it works. could any one help? This is my code: <div class="progress-bar progress-bar-slider"> <input class="progress-slider" type="range" min="4" max="12" ng-model="workingHoursSelectedRange"> <div class="inner" ng-style="{width: workingHoursSelectedRange +

Angular ng-style for ::after

a 夏天 提交于 2019-12-02 07:26:14
I am designing a dynamic hr (horizonatal) rule. In my Style sheet hr.my-hr:after{ content:'Generic' } In my template <div ng-repeat="name in ['Adam', 'Collin', 'David']"> <hr class="my-hr" ng-style="{'content':name}"> But how do i dynamically change the content in the template when using ng-repeat ???? All ng-style does is add inline styles. However you want to add a psuedo element ::after . According to the MDN : You can use only one pseudo-element in a selector. It must appear after the simple selectors in the statement. So inferred from that you can't use them inline, which sadly means ng

Problems using angular ng-style, not updating in IE

若如初见. 提交于 2019-12-01 17:36:46
I've created a simple directive in Angular which generates a scroller to display some products. I'm having an issue with one part of the code. <ul ng-style="{'margin-left':{{currentMargin}}+'px'}"> <li ng-repeat="tyre in tyres" ng-style="{'width':{{liWidth}}+'px'}"> <div class="imageContainer"><img src="../Images/eutl/{{tyre.image}}"/></div> <div class="details"> <h3>{{tyre.name}}</h3> <a href="{{tyre.link}}">About this tire</a> </div> </li> </ul> and this is what it looks like in the browser once executed <ul ng-style="{'margin-left':0+'px'}"> <!-- ngRepeat: tyre in tyres --> <li ng-repeat=