angularjs-ng-repeat

AngularJS (Material) - Refreshing data in md-list after adding new object using md-dialog

 ̄綄美尐妖づ 提交于 2019-12-10 18:35:13
问题 I'm fairly new to the whole Angular world, but yesterday I ran into a problem I cannot seem to fix. As a prototype I'm creating a simple Task application which enables the user to create, view and delete tasks. A new task can be created by clicking a button which opens the dialog. Some information can be given in and by clicking "add task" the task gets added to the database. The only problem is, after the dialog closes the md-list, which displays a list of items, does not refresh to show the

directive can not ''require:ngRepeat'

こ雲淡風輕ζ 提交于 2019-12-10 17:38:10
问题 I write below directive to make call a function when ngRepeat element gets rendered on UI. Directive directives.directive('repeatDone', function() { return { restrict: 'A', require: 'ngRepeat', link: function(scope, element, attrs, ngModel) { if (scope.$last) { scope.$eval(attrs.repeatDone); } } }; }); But it is giving $compile error. If I remove require part, it works OK. Why AngularJS can not accept "require: 'ngRepeat'"? Help would appreciated. 回答1: require is used for accessing the

Angular validation in an ng-repeat not working

久未见 提交于 2019-12-10 17:07:09
问题 I'm having difficulty getting the validation to work using an ng-repeat statement. I have the following code. I just want the has-error to be added to the div.form-group when the name field is empty. I cant seem to get it work. Any thoughts? My Attempt in fiddler <div ng-app="app" ng-controller="bookController"> <form name="myForm" ng-submit="submitMe(this)" novalidate> <table class="table"> <tr ng-repeat="order in orders"> <ng-form name="innerForm"> <td>{{ order.id }}</td> <td> <div class=

ng-repeat dynamic variable name

橙三吉。 提交于 2019-12-10 16:33:31
问题 I am implementing ng-repeat to create elements for a bootstrap accordion interface. I have ng-repeat working however the issue I have is that I need to dynamically create the ID in order to target the accordion element individually. My ng-repeat HTML block references: <div class="panel-heading" data-toggle="collapse" data-parent="#products-accordion" href="#collapseOne"> And lower down references: <div id="collapseOne" class="panel-collapse collapse in"> For this to work correctly,

why ng-repeat changes order of link function execution

情到浓时终转凉″ 提交于 2019-12-10 14:56:39
问题 The usual order of execution of compile and link function on nested directives is as below Markup <dir1> <div dir2=""> </div> </dir1> Order of execution 1) compile of directive 1 2) compile of directive 2 3) link of directive 2 4) link of directive 1 Assuming dir1 has restrict property set to 'E' and dir2 has restrict set to 'A' Now if you use a ng-repeat directive in the same markup, the order of execution changes Markup <dir1> <div ng-repeat="item in items"> <div dir2=""> </div> </div> <

Setting ng-controller dynamically from a variable value

一曲冷凌霜 提交于 2019-12-10 13:58:13
问题 I am developing an application using angularJs and nodejs. Am struck at setting the name of the controller to the value of a variable from main controller. To explain it better, my index.html looks like this : <tbody ng-repeat="group in groups"> <tr ng-repeat="member in group.members" > <td rowspan="{{group.members.length}}" ng-hide="$index>=0"> </td> <td>{{member.taskName}}</td> <td><div class={{group.colorMe[0]}}>{{member.env}}</div> <button class="btn btn-info" ng-controller="member

why Ng Repeat is not working if button invoked from a different form?

偶尔善良 提交于 2019-12-10 12:38:43
问题 I have a html table that contains an ng repeat directive and two button.The first one will open a modal that contains a new form and let me create my user and then when i click save it will add it to the list.The second one is in the same original form and do the add a user. What i did not understand why when i click on the first button which is in a different form i can not update the ng repeat however for the second one it's possible. This is the code: homepage.jsp <body ng-app="myApp">

If else conditions in angularjs templates

不问归期 提交于 2019-12-10 12:34:10
问题 I am quite new to AngularJs. I am working on a Q&A Application where i have to render some questions and its answers in the form of a table. I have three Types of questions which I have to render in a different way. Every question has a type assigned with it. If question.type is "MCQ" then the options or its answer should be rendered with HTML checkbox, and if question type is NUM its answers should be rendered with radio buttons. i tried this and use if conditions in AngularJs Template. my

Referencing a Nested Javascript Object dynamically

僤鯓⒐⒋嵵緔 提交于 2019-12-10 12:22:21
问题 I have an array of objects ( $scope.fields ) that define how input fields should be set up for the $scope.data object model. The fieldName property is actually the path in the data Object to the field. Nested objects are separated by a period mark. eg: $scope.data = { user: { } } $scope.fields = [ {fieldName:'user.firstName',fieldLabel:'First Name',dsiabled:false} {fieldName:'user.location.lat',fieldLabel:'Latitude',dsiabled:false} {fieldName:'user.location.long',fieldLabel:'Latitude'

In AngularJS, what is the correct way to filter an array based on odd or even $index property?

江枫思渺然 提交于 2019-12-10 11:41:59
问题 I want to filter an array based on even and odd $index property and I want to add odd elements in a separate div and even elements in another div, I could easily do this in JavaScript or jQuery, but I wanted to know the correct way to implement the same in AngularJS. This is what I've done so far: <div ng-app> <div ng-init="names=['John', 'Mary', 'Cate', 'Suz']"> <div class="row" ng-repeat="name in names"> <div class="col-xs-6" ng-show="(($index + 1)%2) == 0">{{name}}</div> <div class="col-xs