Commit ed04fce4 authored by Ilya Shulgin's avatar Ilya Shulgin

Ссылки, работающие ну оч криво

parent 81f69797
class CreateController {
constructor($scope, $location, $http) {
$scope.contents = [
{name: "link2", value: "Дополнительное поле для ссылки"},
{name: "link3", value: "Дополнительное поле для ссылки"},
{name: "link4", value: "Дополнительное поле для ссылки"},
{name: "link5", value: "Дополнительное поле для ссылки"}];
$scope.link = ["", "", "", "", ""];
$scope.contents = [];
let number = 1;
let max = 4;
let value = "Дополнительное поле для ссылки";
$scope.show = (id) => {
if (number <= max && $scope.link[number - 1].length === 1) {
$scope.contents.push({number: number, name: "link" + number, value: value});
number++;
}
if ($scope.link[id].length === 0 && id > 0 && (id === $scope.contents.length - 1) && ($scope.link[id + 1].length === 0)) {
$scope.contents.pop();
number--;
}
// $scope.contents.push($scope.contents[id]);
// $scope.link.slice(id, 1);
// $scope.contents.pop();
// $scope.contents.slice(id, 1);
// for (let i = 1; i < $scope.contents.length; i++) {
// $scope.contents[i].number = i;
// $scope.contents[i].name = "link" + i;
// }
//
// number = $scope.contents.length;
};
// $scope.contents = [
// {name: "link2", value: value},
// {name: "link3", value: value},
// {name: "link4", value: value},
// {name: "link5", value: value}];
}
}
......
......@@ -16,9 +16,9 @@
<label for="link1">
Ссылки:
</label>
<input type="text" id="link1" class="form-control" placeholder="Краткое описание вашей новости">
<input type="text" ng-model="link[0]" ng-change="show(0)" name="link1" id="link1" class="form-control" placeholder="Краткое описание вашей новости">
<div ng-repeat="content in contents">
<input type="text" class="form-control" name="{{content.name}}" placeholder="{{content.value}}"/>
<input type="text" ng-model="link[content.number]" ng-change="show(content.number)" class="form-control" name="{{content.name}}" placeholder="{{content.value}}"/>
</div>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment