angularjs-ng-repeat

Angularjs: Compile ng-repeat dynamically

独自空忆成欢 提交于 2021-02-19 05:33:36
问题 I have found some strange behavior with Angularjs. My directive simply adds and compiles ng-repeat to my dom element. However the scope variable item is not accessible. Look at the code below for explanation. var demo = angular.module('demo', []); demo.directive('customRepeat', function($compile) { return { priority: 2000, restrict: 'A', compile: function(element){ element.attr('ng-repeat', 'item in [1,2,3,4,5,6]') return function(scope, element) { $compile(element)(scope) } } } }); <script

AngularJS - hide/show div if date is within last 6 months

十年热恋 提交于 2020-12-08 02:20:52
问题 I have an ng-repeat that displays a list of dates, and information about purchases on that dates. HTML: <div ng-repeat="data in MyData"> <p> {{ data.purchasedOn.substring(6, data.purchasedOn.length - 2) | date:'dd/MM/yyyy' }} </p> <br> <p> {{ data.purchaseDescription }} </p> </div> Which displays: 01/02/2013 "Lorem ipsum dolor sit amet, consectetur adipisicing elit" 10/04/2014 "Lorem ipsum dolor sit amet, consectetur adipisicing elit" 02/08/2014 "Lorem ipsum dolor sit amet, consectetur

Cannot create property 'selected' on string 'Information Technology' angularjs

点点圈 提交于 2020-05-02 04:23:12
问题 This is my controller $scope.subjects = ["Computer Security", "Graphics and Multimedia", "Networks", "Computer Science and Engineering", "Game Design", "Programming", "Information Technology", "Software Engineering", "Technology Management", "Telecommunications", "Web Development", "Sociology", "Psychology", "General", "Social Work", "Criminal Justice", "Law and Paralegal", "Public Safety", "Forensic Sciences", "Counseling", "Homeland Security", "Political Science", "Public Administration"];

:first-child with ng-repeat

核能气质少年 提交于 2020-02-20 08:18:49
问题 I have an ng-repeat and only want to apply a style to the first div with the class type in the ng-repeat. <div class="my-list" ng-repeat="item in list"> <div class="type"> <span>{{item.label}}</span> </div> <div class="check"> <span>{{item.ischecked}}</span> </div> </div> I have tried the following but it applied the CSS to all the divs with a class of type .my-list .type:first-child 回答1: You can use $first , that indicates the first iteration within a ng-repeat . <div class="my-list" ng

:first-child with ng-repeat

被刻印的时光 ゝ 提交于 2020-02-20 08:17:07
问题 I have an ng-repeat and only want to apply a style to the first div with the class type in the ng-repeat. <div class="my-list" ng-repeat="item in list"> <div class="type"> <span>{{item.label}}</span> </div> <div class="check"> <span>{{item.ischecked}}</span> </div> </div> I have tried the following but it applied the CSS to all the divs with a class of type .my-list .type:first-child 回答1: You can use $first , that indicates the first iteration within a ng-repeat . <div class="my-list" ng

Update an Angular variable in the view

*爱你&永不变心* 提交于 2020-02-07 17:14:43
问题 I would like my output to read 0 01 012 0123 01234 etc... I expected this simple code I wrote to do the trick, but instead it prints 01111111111 011111111111 02222222222 022222222222 03333333333 033333333333 04444444444 044444444444 05555555555 055555555555 06666666666 066666666666 Why is this happening? This is my Angular code: <div ng-app="App" ng-controller="ctrl"> <div ng-repeat="num in [1, 2, 3, 4, 5, 6]"> <label>{{previousNumber}}</label> {{previousNumber = (previousNumber + "" + num)}}

Update an Angular variable in the view

梦想的初衷 提交于 2020-02-07 17:13:44
问题 I would like my output to read 0 01 012 0123 01234 etc... I expected this simple code I wrote to do the trick, but instead it prints 01111111111 011111111111 02222222222 022222222222 03333333333 033333333333 04444444444 044444444444 05555555555 055555555555 06666666666 066666666666 Why is this happening? This is my Angular code: <div ng-app="App" ng-controller="ctrl"> <div ng-repeat="num in [1, 2, 3, 4, 5, 6]"> <label>{{previousNumber}}</label> {{previousNumber = (previousNumber + "" + num)}}