угловой
Все используемые библиотеки, CDN использовали:
Кода -копия выглядит следующим образом:
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
. Angular для привязки данных, это самый простой, все ветви и листья углового запуска отсюда:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Самое мощное в угловом - связывание связывания данных
</div>
<div>
<div id = "bind" ng-controller = "bf">
<input type = "text" ng-model = "data" />
{{данные}}
<Скрипт>
app.controller ("bf", function ($ scope) {
$ scope.data = "testdata";
// $ scope. $ Apply ();
});
</script>
</div>
</div>
</div>
</body>
</html>
Через угловой отображение соответствующих данных массива;.
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Через угловой отображение соответствующих данных массива;
</div>
<div>
<div id = "arr-bind" ng-app = "arr-app" ng-controller = "arrcon">
<style>
.s {
Цвет:#F00;
}
li {
курсор: указатель;
}
</style>
<ul>
<li ng-repeat = "i в списках" ng-click = "bered ($ index)" ng-class = "{s: $ index == flag}">
{{i.name}} ---- {{i.age}}
</li>
</ul>
<Скрипт>
//angular.module("Arr-app ", []);
Функция arrcon ($ scope) {
$ scope.flag = 0;
$ scope.bered = function (i) {
$ scope.flag = i;
};
$ scope.lists = [
{имя: "хе -хе",
Возраст: 10},
{
Имя: "xx",
Возраст: 20
},
{
имя: "yy",
Возраст: 2
},
{
Имя: "JJ",
Возраст: 220
}
]
};
</script>
</div>
</div>
</div>
</body>
</html>
Демо из фильтра данных:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Фильтр данных;
</div>
<div ng-controller = "filte">
{{sourcode}}
<br>
{{Sourcode | вверх}}
</div>
<Скрипт>
Функциональный фильтр ($ scope) {
$ scope.sourcode = "hehe lala dudu oo zz";
};
app.filter ("up", function () {
вернуть функцию (ipt) {
return ipt.replace (/(/w)/g, функция ($ 0, $ 1) {
вернуть ""+$ 1. touppercase ();
});
}
});
</script>
</div>
</body>
</html>
. Факторная фабрика, $ поставщик, услуга и т. Д. Все одинаковы. Не чувствую, что это сложно. На самом деле, это просто увидеть модель данных или экземпляр;:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div id = "factory">
<div>
Фабрика в угловой, эквивалентной методу общего экземпляра, который можно понимать как функция, которая может использоваться несколькими контроллерами;
</div>
<div ng-controller = "factory">
{{json}}
<Скрипт>
app.factory ("ff", function () {
возвращаться {
"Отметить": "Json"
};
});
app.controller ("factory", function ($ scope, ff) {
$ scope.json = ff;
});
</script>
</div>
</div>
<div>
<div>
Угловая директива;
</div>
<div>
<хе -хе -ха -хе? </heh>
<Скрипт>
app.directive ("heh", function () {
возвращаться {
ограничить: "AE",
Заменить: правда,
Transclude: True,
Шаблон: '<div> <кнопка ng-transclude> </button> </div>'
};
})
</script>
</div>
</div>
</body>
</html>
Использование директивы .ng-Switch (я действительно хочу этот шаблон, который является угловым нашим общим кликом, чтобы сначала скрыть и отобразить плагин вкладок) ::
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Использование NG-Switch
</div>
<div ng-controller = "sw">
<div ng-init = "a = 2">
<ul ng-switch on = "a">
<li ng-switch-when = "1"> 1 </li>
<li ng-switch-when = "2"> 2 </li>
<li ng-switch-default> Другой </li>
</ul>
</div>
<div>
<кнопка ng-click = "a = 1"> тест </button>
<кнопка ng-click = "a = 2"> тест </button>
<кнопка ng-click = "a = 3"> тест </button>
</div>
</div>
<script type = "text/javascript">
app.controller ("sw", function ($ scope) {
});
</script>
</div>
</body>
</html>
ng-src и ng-href;
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Использование NG-SRC и NG-HREF (если вы используете SRC или HREF, HTML будет загружен при его инициализации, что определенно невозможно)
</div>
<div ng-controller = "srccon">
<a ng-href = "{{logo}}">
<img ng-src = "{{logo}}" />
</a>
</div>
<script type = "text/javascript">
app.controller ("srccon", function ($ scope) {
$ scope.logo = "http://www.mainbo.com/templets/images/logo.gif";
});
</script>
</div>
</body>
</html>
Как управлять стилем страницы, просто измените модель связанных данных напрямую:
Кода -копия выглядит следующим образом:
<div>
<div>
Angular работает на стилях; (JQ должен вручную выбирать элементы для работы на стилях элементов. Angular предоставляет более метод назначения атрибутов элемента переменной, вам просто нужно изменить эту переменную)
</div>
<div>
<hehehe id = "wh" ng-style = "{width: w + 'px', высота: h + 'px', founalcolor: '#364'}">
хе-хе-о (^^) о вау;
</hehe>
</div>
<script type = "text/javascript">
app.directive ("hehehe", function () {
функция compile () {
};
возвращаться {
Ссылка: функция ($ scope, $ element) {
var obj = angular.element ($ element);
//obj.find нелегко использовать;
var add = obj [0] .getElementsbyclassname ("add") [0];
var уменьшить = obj [0] .getElementsbyclassname ("уменьшить") [0];
Angular.Element (add) .bind ("click", function () {
$ scope.h = $ scope.h+10;
применять();
})
Angular.Element (уменьшить) .bind ("click", function () {
$ scope.h = $ scope.h-10;
применять();
});
функция Apply () {
$ scope. $ Apply ();
}
вернуть компиляцию;
},
Контроллер: функция ($ scope) {
$ scope.w = 200;
$ scope.h = 50;
// $ scope. $ Apply ();
},
ограничить: «аэ»,
Заменить: правда,
Применение: "= ng-стиль",
Transclude: True,
Шаблон: '<div> <div ng-transclude> </div> <tood>+</button> <tutry>-</button> </div>'
}
})
</script>
</div>
Как использовать шаблон в угловой? Это должно использоваться с маршрутизатором:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Используя шаблоны
</div>
<div ng-controller = "ngtpl">
<! --- Этот тип должен быть объявлен точно->
<script type = "text/ng-template" id = "tpl">
{{ver}}
</script>
<! --- TPL-это фиксированное значение, а не переменная, а переменная должна быть определена в области --->
<div ng-include src = "'tpl'"> </div>
<div>
<кнопка ng-click = "chan ()"> изменить </button>
</div>
</div>
<script type = "text/javascript">
app.controller ("ngtpl", function ($ scope) {
функция хе -хе (str) {
str = _.shuffle (str);
вернуть str.join ("")
};
$ scope.ver = "var-ver-heehehe";
$ scope.chan = function () {
$ scope.ver = хе -хе ($ scope.ver);
};
});
</script>
</div>
</body>
</html>
Как использовать $ scope. $ Смотрите, чтобы изменить шаблон интерфейса привязки в режиме реального времени:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
<pran> Обновление </span> Агловидному уведомлению
</div>
<div ng-controller = "Apply">
{{хе -хе}}
<input type = "text" ng-model = "m0" />
<div>
Значение, установленное $ scope. $ watch == >> {{wat}}
</div>
<br>
<button ng-click = "up ()">
применять;
</button>
</div>
<script type = "text/javascript">
app.controller ("Apply", function ($ scope) {
$ scope.hehe = "lll____________xxx";
$ scope.m0 = 1;
SS = $ Scope;
$ scope.up = function () {
$ scope.hehe = $ scope.m0;
// Да, но была сообщена ошибка, когда была дана подсказка. Кто знает почему?
// $ scope. $ Apply ();
$ scope. $ Digest ();
};
// дайте $ acfope.m0 переменная быть недействительной;
$ scope. $ watch ("m0", function (va) {
$ scope.wat = va;
})
});
</script>
</div>
</body>
</html>
Метод инструмента, который вы определяете себя в угловом
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Список метода инструментов в угловом
</div>
<div>
<ul>
<li role = "presentation"> <a href = "###"> angular.bind </a> </li>
<li role = "presentation"> <a href = "###"> angular.bootstrap </a> </li>
<li rol = "presentation"> <a href = "###"> angular.copy </a> </li>
<li rol = "presentation"> <a href = "###"> angular.element </a> </li>
<li role = "presentation"> <a href = "###"> angular.equals </a> </li>
<li role = "presentation"> <a href = "###"> angular.extend </a> </li>
<li rol = "presentation"> <a href = "###"> angular.foreach </a> </li>
<li rol = "presentation"> <a href = "###"> angular.fromjson </a> </li>
<li rol = "presentation"> <a href = "###"> angular.identity </a> </li>
<li rol = "presentation"> <a href = "###"> angular.injector </a> </li>
<li rol = "presentation"> <a href = "###"> angular.isarray </a> </li>
<li rol = "presentation"> <a href = "###"> angular.isdate </a> </li>
<li rol = "presentation"> <a href = "###"> angular.isdefined </a> </li>
<li rol = "presentation"> <a href = "###"> angular.iselement </a> </li>
<li rol = "presentation"> <a href = "###"> angular.isfunction </a> </li>
<li role = "presentation"> <a href = "###"> angular.isnumber </a> </li>
<li role = "presentation"> <a href = "###"> angular.isobject </a> </li>
<li rol = "presentation"> <a href = "###"> angular.isstring </a> </li>
<li role = "presentation"> <a href = "###"> angular.isundefined </a> </li>
<li role = "presentation"> <a href = "###"> angular.lowercase </a> </li>
<li role = "presentation"> <a href = "###"> angular.module </a> </li>
<li role = "presentation"> <a href = "###"> angular.noop </a> </li>
<li role = "presentation"> <a href = "###"> angular.ReloadWithDebuginfo </a> </li>
<li rol = "presentation"> <a href = "###"> angular.tojson </a> </li>
<li rol = "presentation"> <a href = "###"> angular.Uppercase </a> </li>
</ul>
<div>
Эти инструменты и методы похожи на другие библиотеки;
Angular.Element - это небольшой JQ для элемента выбора ангаарлитов;
<br>
Angular.Module - это метод модульных элементов;
</div>
</div>
</div>
</body>
</html>
Использование NG-TransClude (это официальный случай), код заключается в следующем:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Использование NG-TransClude (это официальный случай):
</div>
<div ng-controller = "examplecontroller">
<div>
<input ng-model = "title"> <br>
<textarea ng-model = "text"> </textarea> <br/>
<pane> {{text}} </pane>
</div>
</div>
<script type = "text/javascript">
app.directive ('pane', function () {
возвращаться {
ограничить: 'e',
Transclude: True,
Scope: {title: '@'},
Шаблон: '<div style = "border: 1px solid black;">' +
'<div style = "founal-color: grey"> {{title}} </div>' +
'<ng-transclude> </ng-transclude>' +
'</div>'
};
})
.controller ('examplecontroller', ['$ scope', function ($ scope) {
$ scope.title = 'lorem ipsum';
$ scope.text = 'nequ porno quisquam est qui dolorem ipsum quia dolor ...';
}]);
</script>
</div>
</body>
</html>
Вот пример проверки точности почтового ящика:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
Ngpaste, Ngmouseup, Ngkeyup, Ngmodeloptions и т. Д., См. Официальное использование, просто используйте чек API (официальное потребности FQ;)
</div>
<script src = "https://yearofmoo.github.io/ngmessages/angular-messages.js"> </script>
<div ng-controller = "fromVaild">
Если вы не используете компонент NG-Message, подсказка ошибки заключается в следующем;
<form name = "userform">
<div>
<метка для = "EmailAddress"> Введите свой адрес электронной почты: </label>
<input type = "email" name = "emailaddress" ng-model = "data.email" требуется />
<!-Это слишком сложное->
<div ng-if = "userform.emailaddress. $ error.required">
Вы забыли ввести свой адрес электронной почты ...
</div>
<div ng-if = "! userform.emailaddress. $ error.required &&
userform.emailaddress. $ error.email »>
Вы неправильно ввели свой адрес электронной почты ...
</div>
</div>
<input type = "Отправить" />
</form>
<br>
<a href = "https://yearofmoo.github.io/ngmessage/"> демо, написанное иностранцами </a>
</div>
<script type = "text/javascript">
app.controller ("fromVaild", function ($ scope) {
//$SCOPE.MYFIELD.$ERROR = {minLength: true, обязательно: false};
})
</script>
</div>
</body>
</html>
SETTIMEOUT и SETINTERVAL оба обернуты угловатыми и возвращают экземпляр задерживого объекта:
Кода -копия выглядит следующим образом:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> Angular </title>
<meta http-equiv = "x-ua-совместимый" content = "IE = edge, chrome = 1">
<script src = "http://cdn.bootcss.com/jquery/2.1.1/jquery.js"> </script>
<script src = "http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"> </script>
<link href = "http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel = "styleSheet">
<script src = "http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type = "text/javascript"> </script>
</head>
<body ng-app = "app">
<script type = "text/javascript">
var app = angular.module ("app", []);
</script>
<div>
<div>
$ тайм -аут и интервал $, эти две услуги;
</div>
<div ng-controller = "st">
<div>
<a href = "#">
<h4> setInterval </h4>
<p>
$ интервал (FN, задержка, [count], [invokeapply]);
</p>
</a>
<a href = "#">
<h4> тайм -аут </h4>
<p>
$ timeout (fn, [Delock], [InvokeApply]);
</p>
</a>
</div>
<div>
<div rol = "progressbar" aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100">
0%
</div>
</div>
<кнопка ng-click = "prog ()">
начинать
</button>
</div>
<script type = "text/javascript">
app.controller ("st", function ($ scope, $ element, $ интервал) {
var $ el = $ ($ element [0]). Найти (".. Progress-bar");
console.log (аргументы);
// Использование элемента, выбранного Angular.Element, чтобы найти что -то без поиска;
$ scope.prog = function () {
var df = $ интервал (function () {
var val = parseint ($ el.html ())+4;
if (val> = 104) $ Interval.cancel (df);
$ el.html (val+"%") .width (val+"%");
}, 100);
Console.log (DF)
//console.log(aa = $ интервал)
};
});
</script>
</div>
</body>
</html>