refactored a little bit

This commit is contained in:
Athou
2013-04-30 22:20:39 +02:00
parent e01da0645d
commit f9aa4995f9
4 changed files with 11 additions and 8 deletions

View File

@@ -237,11 +237,14 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
$scope.CategoryService = CategoryService;
CategoryService.get(function() {
for(var i = 0; i < CategoryService.flatCategories.length; i++){
for (var i = 0; i < CategoryService.flatCategories.length; i++) {
var cat = CategoryService.flatCategories[i];
if (cat.id == $stateParams._id) {
$scope.category = angular.copy(cat);
$scope.category.name = $scope.category.origName;
$scope.category = {
id: cat.id,
name: cat.orig.name,
parentId: cat.orig.parentId,
}
break;
}
}

View File

@@ -104,7 +104,7 @@ function($resource, $http) {
array.push({
id : category.id,
name : name,
origName: category.name
orig: category
});
if (category.children) {
for ( var i = 0; i < category.children.length; i++) {

View File

@@ -33,8 +33,8 @@
<div class="control-group" ng-class="{error : !subscribeForm.category.$valid}">
<label class="control-label">Category</label>
<div class="controls">
<select name="category" ng-model="sub.categoryId" class="input-block-level" required>
<option ng-repeat="cat in CategoryService.flatCategories" value="{{cat.id}}">{{cat.name}}</option>
<select name="category" ng-model="sub.categoryId" class="input-block-level"
ng-options="cat.id as cat.name for cat in CategoryService.flatCategories" required>
</select>
<span class="help-block" ng-show="!subscribeForm.category.$valid">Required</span>
</div>

View File

@@ -14,7 +14,7 @@
<div class="control-group" ng-class="{error : !form.category.$valid}">
<label class="control-label">Parent category</label>
<div class="controls">
<select name="category" class="input-block-level" ng-model="cat.parentId"
<select name="category" class="input-block-level" ng-model="category.parentId"
ng-options="cat.id as cat.name for cat in CategoryService.flatCategories">
</select>
<span class="help-block" ng-show="!form.category.$valid">Required</span>
@@ -24,7 +24,7 @@
<div class="control-group">
<label class="control-label">Feed URL</label>
<div class="controls horizontal-align">
<a href="{{'rest/category/entriesAsFeed?id=' + cat.id}}" target="_blank">{{'rest/category/entriesAsFeed?id=' + cat.id}}</a>
<a href="{{'rest/category/entriesAsFeed?id=' + category.id}}" target="_blank">{{'rest/category/entriesAsFeed?id=' + category.id}}</a>
</div>
</div>