Skip to content

Commit

Permalink
fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
RyujiAMANO committed May 18, 2015
1 parent caf0d2e commit 0a16368
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions webroot/js/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Created by ryuji on 15/04/30.
*/
NetCommonsApp.controller('Tags.TagEdit',
function($scope, $filter, $http) {
function($scope, $filter, $http, filterFilter) {
var where = $filter('filter');

$scope.frameId = 0;
Expand All @@ -11,25 +11,30 @@ NetCommonsApp.controller('Tags.TagEdit',


$scope.init = function(frameId, modelName, tags) {
console.log(tags);
if (tags) {
$scope.tags = tags;
}
console.log($scope.tags);
$scope.modelName = modelName;
$scope.frameId = frameId;
};

$scope.newTag = '';


$scope.tagExist = function(newTag) {
var result = filterFilter($scope.tags, newTag);
return (result.length > 0);
};

$scope.addTag = function() {
if ($scope.newTag.length > 0) {
$scope.tags.push({
name: $scope.newTag
});
$scope.newTag = '';
$scope.showResult = false;

if ($scope.tagExist($scope.newTag) === false) {
$scope.tags.push({
name: $scope.newTag
});
$scope.newTag = '';
$scope.showResult = false;
}
}
};

Expand Down

0 comments on commit 0a16368

Please sign in to comment.