diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000..c6439c8d70e7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 8030f8d77761..3142dc3b70ea 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,5 @@ performance/temp*.html *~ angular.js.tmproj node_modules -jsTestDriver*.conf angular.xcodeproj .idea diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000000..d209a1b20618 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: node_js +node_js: + - 0.8 + +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - npm install -g testacular@canary + - rake package + - ./nodeserver.sh > /dev/null & + +script: + - rake test[Firefox,"--reporters=dots"] diff --git a/CHANGELOG.md b/CHANGELOG.md index bb963e6a4cc2..c0b68ef134bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,99 @@ + +# 1.1.0 increase-gravatas (2012-08-31) + +_Note: 1.1.x releases are [considered unstable](http://blog.angularjs.org/2012/07/angularjs-10-12-roadmap.html)._ + +## Features + +- **$http:** support custom reponseType + ([e0a54f6b](https://github.com/angular/angular.js/commit/e0a54f6b206dc2b6595f2bc3a17c5932e7477545), + [#1013](https://github.com/angular/angular.js/issues/1013)) +- **$interpolate:** + - provide contextual error messages + ([d804bbcd](https://github.com/angular/angular.js/commit/d804bbcd51ec83bee1f4a3ccd42c3bd7eb38a988)) + - expose start/end symbols in run phase + ([58f121a5](https://github.com/angular/angular.js/commit/58f121a5c293ed57043e22ed526fdf99642fca81)) +- **$sniffer:** auto detect CSP mode (currently requires Chrome on dev channel) + ([167aa0c2](https://github.com/angular/angular.js/commit/167aa0c29c998be33c49d33302e099b36d1ce0be)) + +This release also contains all bug fixes available in [1.0.2](#1.0.2). + + + + +# 1.0.2 debilitating-awesomeness (2012-08-31) + + +## Bug Fixes + +- **$compile:** denormalize directive templates + ([dfe99836](https://github.com/angular/angular.js/commit/dfe99836cd98c2a1b0f9bde6216bd44088de275a)) +- **$interpolate:** $interpolateProvider.endSymbol() returns startSymbol + ([20348717](https://github.com/angular/angular.js/commit/20348717640c0ef405c9fdcc8fec5b566efc48b3)) +- **jqLite:** better support for xhtml + ([d3fa7a2e](https://github.com/angular/angular.js/commit/d3fa7a2e9e93c9dae13d852b28c878f7d6b7c420), + [#1301](https://github.com/angular/angular.js/issues/1301)) +- **mocks:** free up memory after every spec + ([1a8642aa](https://github.com/angular/angular.js/commit/1a8642aac2de40dccdab464e58dc164006c300bb)) +- **e2e test runner:** Adding meta tag to avoid cache issues + ([5318588d](https://github.com/angular/angular.js/commit/5318588d6e8ee9a31f4002affd6858d25305aabf)) +- Directives: + - **form:** prevent page reload when form destroyed + ([054d40f3](https://github.com/angular/angular.js/commit/054d40f338f9000cddcf7f0513af37328b88ef41), + [#1238](https://github.com/angular/angular.js/issues/1238)) + - **ngList:** remove data bound flicker + ([fa62ea81](https://github.com/angular/angular.js/commit/fa62ea810f6c701e898dd07c6c9228f13d5b5e02)) + - **ngPluralize:** fixes ng-pluralize when using non-standard start/end symbols + ([e85774f7](https://github.com/angular/angular.js/commit/e85774f709b9f681b0ff8d829b07568b0f844a62), + [#1134](https://github.com/angular/angular.js/issues/1134)) + - **option:** support option elements in datalist + ([9767f7bd](https://github.com/angular/angular.js/commit/9767f7bdd3e1ce6f65bdea992d67369ead13d813), + [#1165](https://github.com/angular/angular.js/issues/1165)) + + +## Docs + +- Conceptual Overview of AngularJS (high level overview of how things work): + + ([7a5f25f6](https://github.com/angular/angular.js/commit/7a5f25f6671eb5f51b06615d74a05855ab79f31e)) +- Lots of spelling, grammar and other fixes: + [9a710c78](https://github.com/angular/angular.js/commit/9a710c788d880785d2b02a9c5411eb15e9c278bf), + [847d2da0](https://github.com/angular/angular.js/commit/847d2da0f8d1e265eda7b4dd3e7eb52ac86d784e), + [dbefd671](https://github.com/angular/angular.js/commit/dbefd671e41c3bda481850bb7e566349e275d759), + [cab5e1d9](https://github.com/angular/angular.js/commit/cab5e1d9b363eac6fd31b15c5b86f30993e2f147), + [f00b6cca](https://github.com/angular/angular.js/commit/f00b6cca024a9418f353651f29c984f934575bd9), + [2e365168](https://github.com/angular/angular.js/commit/2e3651686c2bd84cf464ecc236c8ad77e61179df), + [536de148](https://github.com/angular/angular.js/commit/536de148214290f0b4a0595fa16c00da5e527e79), + [a1107e81](https://github.com/angular/angular.js/commit/a1107e81ebf2254caf75718de2e3ec773cce0c56), + [5ef9ed87](https://github.com/angular/angular.js/commit/5ef9ed87d82b109715a87e9aa1b1d5b63f515d3a), + [8c81a0f3](https://github.com/angular/angular.js/commit/8c81a0f3728b9308854ceb9bf392ec467b95d8eb), + [bde931af](https://github.com/angular/angular.js/commit/bde931afd5cf2483df236e06992666a0a4182794), + [6553fe68](https://github.com/angular/angular.js/commit/6553fe68d17d42ec25e0c592ceaa1077cc0ec4f6), + [13b5fd1b](https://github.com/angular/angular.js/commit/13b5fd1b9d60f1a9187da8a89db9272284ccdac4), + [17209d5b](https://github.com/angular/angular.js/commit/17209d5b4a579edf8425715b5cdf25bc5cd96711), + [31c82560](https://github.com/angular/angular.js/commit/31c825607dd524241c811ca3e401b119c810e977), + [ab6937e2](https://github.com/angular/angular.js/commit/ab6937e2518bfd77d9fe42e3d2e11fe4a7a16814), + [fbfda241](https://github.com/angular/angular.js/commit/fbfda241f616bcfe8273f501dd49120a3cb35fab), + [206371b7](https://github.com/angular/angular.js/commit/206371b7372c242db234ca8da12d1c7a8a322d54), + [b6b92bd8](https://github.com/angular/angular.js/commit/b6b92bd866e1d6d066f1c9bf1937496cd3e28664), + [79f2d843](https://github.com/angular/angular.js/commit/79f2d843a8458bfdc23fe9f179a1416fe21f7533), + [64a9cd8f](https://github.com/angular/angular.js/commit/64a9cd8f4fac1c518869a1c955fe60bd6ef76439), + [7f6e1326](https://github.com/angular/angular.js/commit/7f6e1326f3a7a6a2ba2dbd48dd6571ebe929a7c1), + [1fd2b3d4](https://github.com/angular/angular.js/commit/1fd2b3d402f36e395a1fe9ea7e3f91a1b2833426), + [d56d69cc](https://github.com/angular/angular.js/commit/d56d69cc8319f69135a17a9bb5ae394123b33c51), + [01e726b2](https://github.com/angular/angular.js/commit/01e726b2fa3fb0d2584c9bb8df116ff3a9f05879), + [16136216](https://github.com/angular/angular.js/commit/161362164532af3578c9e3e8b52cd80b15345add), + [92a3d282](https://github.com/angular/angular.js/commit/92a3d2821856c75eb95f8ec6ccf26d6a9b37fdd9), + [4c585019](https://github.com/angular/angular.js/commit/4c5850195699b1d982963f25399d24bf8b815f81), + [c076fe08](https://github.com/angular/angular.js/commit/c076fe08cf47e8af4b5e8845aed917ebb7dbd593), + [2473412b](https://github.com/angular/angular.js/commit/2473412ba55f7c47f2ca24311312ce95ee11949e), + [1f2d5000](https://github.com/angular/angular.js/commit/1f2d50000e82630bfce6eb9cf0a8da752fd1e826), + [5026315d](https://github.com/angular/angular.js/commit/5026315d6f4495d636d86ae2a022fb55cc0ca211), + [f0a090dd](https://github.com/angular/angular.js/commit/f0a090ddf256d0c144e705c0cdf4216d824140f9), + [6d9313a6](https://github.com/angular/angular.js/commit/6d9313a68d82654d389c0b2c3e4af148382f14be)) and more! + + + # 1.0.1 thorium-shielding (2012-06-25) diff --git a/README.md b/README.md index b6a98cad3474..f29dd2dd0f1e 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,31 @@ it makes development fun! * Tutorial: http://docs.angularjs.org/tutorial * API Docs: http://docs.angularjs.org * Developer Guide: http://docs.angularjs.org/guide +* Contribution guidelines: http://docs.angularjs.org/misc/contribute -Compiling +Building AngularJS --------- - rake compile +[Once you have your environment setup](http://docs.angularjs.org/misc/contribute) just run: + + rake package + Running Tests ------------- - ./server.sh # start the server - open http://localhost:9876/capture # capture browser - ./test.sh # run all unit tests +Running tests requires installation of [Testacular](http://vojtajina.github.com/testacular): + + sudo npm install -g testacular + +To execute all unit tests, use: + + rake test:unit + +To execute end-to-end (e2e) tests, use: + rake package + rake webserver & + rake test:e2e +To learn more about the rake tasks, run `rake -T` and also read our +[contribution guidelines](http://docs.angularjs.org/misc/contribute) and instructions in this +[commit message](https://github.com/angular/angular.js/commit/9d168f058f9c6d7eeae0daa7cb72ea4e02a0003a). diff --git a/Rakefile b/Rakefile index 9c18da9dc728..3a8cc00ee34a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,13 @@ require 'yaml' include FileUtils + +## High level flow of the build: +## +## clean -> init -> concat -> minify -> package +## + + content = File.open('angularFiles.js', 'r') {|f| f.read } files = eval(content.gsub(/\};(\s|\S)*/, '}'). gsub(/angularFiles = /, ''). @@ -9,7 +16,7 @@ files = eval(content.gsub(/\};(\s|\S)*/, '}'). BUILD_DIR = 'build' -task :default => [:compile, :test] +task :default => [:package] desc 'Init the build workspace' @@ -19,12 +26,13 @@ task :init do v = YAML::load( File.open( 'version.yaml' ) ) match = v['version'].match(/^([^-]*)(-snapshot)?$/) - NG_VERSION = Struct.new(:full, :major, :minor, :dot, :codename). + NG_VERSION = Struct.new(:full, :major, :minor, :dot, :codename, :stable). new(match[1] + (match[2] ? ('-' + %x(git rev-parse HEAD)[0..7]) : ''), match[1].split('.')[0], match[1].split('.')[1], match[1].split('.')[2].sub(/\D+.*$/, ''), - v['codename']) + v['codename'], + v['stable']) end @@ -32,11 +40,12 @@ desc 'Clean Generated Files' task :clean do FileUtils.rm_r(BUILD_DIR, :force => true) FileUtils.mkdir(BUILD_DIR) + FileUtils.rm_r('test_out', :force => true) end -desc 'Compile Scenario' -task :compile_scenario => :init do +desc 'Concat Scenario' +task :concat_scenario => :init do concat_file('angular-scenario.js', [ 'lib/jquery/jquery.js', @@ -47,28 +56,10 @@ task :compile_scenario => :init do ], gen_css('css/angular.css') + "\n" + gen_css('css/angular-scenario.css')) end -desc 'Compile JSTD Scenario Adapter' -task :compile_jstd_scenario_adapter => :init do - - concat_file('jstd-scenario-adapter.js', [ - 'src/ngScenario/jstd-scenario-adapter/angular.prefix', - 'src/ngScenario/jstd-scenario-adapter/Adapter.js', - 'src/ngScenario/jstd-scenario-adapter/angular.suffix', - ]) - - # TODO(vojta) use jstd configuration when implemented - # (instead of including jstd-adapter-config.js) - File.open(path_to('jstd-scenario-adapter-config.js'), 'w') do |f| - f.write("/**\r\n" + - " * Configuration for jstd scenario adapter \n */\n" + - "var jstdScenarioAdapter = {\n relativeUrlPrefix: '/build/docs/'\n};\n") - end -end -desc 'Compile JavaScript' -task :compile => [:init, :compile_scenario, :compile_jstd_scenario_adapter] do - +desc 'Concat AngularJS files' +task :concat => :init do concat_file('angular.js', [ 'src/angular.prefix', files['angularSrc'], @@ -98,133 +89,139 @@ task :compile => [:init, :compile_scenario, :compile_jstd_scenario_adapter] do FileUtils.cp 'src/ngMock/angular-mocks.js', path_to('angular-mocks.js') - closure_compile('angular.js') - closure_compile('angular-cookies.js') - closure_compile('angular-loader.js') - closure_compile('angular-resource.js') - closure_compile('angular-sanitize.js') - closure_compile('angular-bootstrap.js') - closure_compile('angular-bootstrap-prettify.js') + rewrite_file(path_to('angular-mocks.js')) do |content| + content.sub!('"NG_VERSION_FULL"', NG_VERSION.full) + end +end + + +desc 'Minify JavaScript' +task :minify => [:init, :concat, :concat_scenario] do + [ 'angular.js', + 'angular-cookies.js', + 'angular-loader.js', + 'angular-resource.js', + 'angular-sanitize.js', + 'angular-bootstrap.js', + 'angular-bootstrap-prettify.js' + ].each do |file| + fork { closure_compile(file) } + end + + Process.waitall +end + +desc 'Generate version.txt file' +task :version => [:init] do + `echo #{NG_VERSION.full} > #{path_to('version.txt')}` end desc 'Generate docs' task :docs => [:init] do `node docs/src/gen-docs.js` - rewrite_file(path_to('docs/.htaccess')) do |content| - content.sub!('"NG_VERSION_FULL"', NG_VERSION.full) + + [ path_to('docs/.htaccess'), + path_to('docs/index.html'), + path_to('docs/index-debug.html'), + path_to('docs/index-nocache.html'), + path_to('docs/index-jq.html'), + path_to('docs/index-jq-debug.html'), + path_to('docs/index-jq-nocache.html'), + path_to('docs/docs-scenario.html') + ].each do |src| + rewrite_file(src) do |content| + content.sub!('"NG_VERSION_FULL"', NG_VERSION.full). + sub('"NG_VERSION_STABLE"', NG_VERSION.stable) + end end end desc 'Create angular distribution' -task :package => [:clean, :compile, :docs] do - tarball = "angular-#{NG_VERSION.full}.tgz" - - pkg_dir = path_to("pkg/angular-#{NG_VERSION.full}") - FileUtils.rm_r(path_to('pkg'), :force => true) - FileUtils.mkdir_p(pkg_dir) - - [ path_to('angular.js'), - path_to('angular.min.js'), - path_to('angular-loader.js'), - path_to('angular-loader.min.js'), - path_to('angular-bootstrap.js'), - path_to('angular-bootstrap.min.js'), - path_to('angular-bootstrap-prettify.js'), - path_to('angular-bootstrap-prettify.min.js'), - path_to('angular-mocks.js'), - path_to('angular-cookies.js'), - path_to('angular-cookies.min.js'), - path_to('angular-resource.js'), - path_to('angular-resource.min.js'), - path_to('angular-sanitize.js'), - path_to('angular-sanitize.min.js'), - path_to('angular-scenario.js'), - path_to('jstd-scenario-adapter.js'), - path_to('jstd-scenario-adapter-config.js'), - ].each do |src| - dest = src.gsub(/^.*\//, '').gsub(/((\.min)?\.js)$/, "-#{NG_VERSION.full}\\1") - FileUtils.cp(src, pkg_dir + '/' + dest) - end +task :package => [:clean, :minify, :version, :docs] do + zip_dir = "angular-#{NG_VERSION.full}" + zip_file = "#{zip_dir}.zip" - FileUtils.cp_r path_to('i18n'), "#{pkg_dir}/i18n-#{NG_VERSION.full}" - FileUtils.cp_r path_to('docs'), "#{pkg_dir}/docs-#{NG_VERSION.full}" + FileUtils.ln_s BUILD_DIR, zip_dir + %x(zip -r #{zip_file} #{zip_dir}) + FileUtils.rm zip_dir - rewrite_file("#{pkg_dir}/angular-mocks-#{NG_VERSION.full}.js") do |content| - content.sub!('"NG_VERSION_FULL"', NG_VERSION.full) - end + FileUtils.mv zip_file, path_to(zip_file) + puts "Package created: #{path_to(zip_file)}" +end - [ "#{pkg_dir}/docs-#{NG_VERSION.full}/index.html", - "#{pkg_dir}/docs-#{NG_VERSION.full}/index-jq.html", - "#{pkg_dir}/docs-#{NG_VERSION.full}/index-nocache.html", - "#{pkg_dir}/docs-#{NG_VERSION.full}/index-jq-nocache.html", - "#{pkg_dir}/docs-#{NG_VERSION.full}/index-debug.html", - "#{pkg_dir}/docs-#{NG_VERSION.full}/index-jq-debug.html" - ].each do |src| - rewrite_file(src) do |content| - content.gsub!(/'angular(.*)\.js/, '\'angular\1-' + NG_VERSION.full + '.js') - end - end + +desc 'Start development webserver' +task :webserver, :port do |t, args| + exec "node lib/nodeserver/server.js #{args[:port]}" +end - rewrite_file("#{pkg_dir}/docs-#{NG_VERSION.full}/docs-scenario.html") do |content| - content.sub!('angular-scenario.js', "angular-scenario-#{NG_VERSION.full}.js") +desc 'Run all AngularJS tests' +task :test, :browsers, :misc_options do |t, args| + [ 'test:jqlite', + 'test:jquery', + 'test:modules', + 'test:e2e' + ].each do |task| + Rake::Task[task].invoke(args[:browsers], args[:misc_options]) end +end - [ "#{pkg_dir}/docs-#{NG_VERSION.full}/appcache.manifest", - "#{pkg_dir}/docs-#{NG_VERSION.full}/appcache-offline.manifest" - ].each do |src| - rewrite_file(src) do |content| - content.sub!('../angular.min.js', "angular-#{NG_VERSION.full}.min.js"). - sub!('/build/docs/', "/#{NG_VERSION.full}/docs-#{NG_VERSION.full}/") +namespace :test do + + desc 'Run all unit tests (single run)' + task :unit, :browsers, :misc_options do |t, args| + [ 'test:jqlite', + 'test:jquery', + 'test:modules' + ].each do |task| + Rake::Task[task].invoke(args[:browsers], args[:misc_options]) end end - %x(tar -czf #{path_to(tarball)} -C #{path_to('pkg')} .) + desc 'Run jqLite-based unit test suite (single run)' + task :jqlite, :browsers, :misc_options do |t, args| + start_testacular('testacular-jqlite.conf.js', true, args[:browsers], args[:misc_options]) + end - FileUtils.cp path_to(tarball), pkg_dir - FileUtils.mv pkg_dir, path_to(['pkg', NG_VERSION.full]) - - puts "Package created: #{path_to(tarball)}" -end + desc 'Run jQuery-based unit test suite (single run)' + task :jquery, :browsers, :misc_options do |t, args| + start_testacular('testacular-jquery.conf.js', true, args[:browsers], args[:misc_options]) + end -namespace :server do - desc 'Run JsTestDriver Server' - task :start do - sh %x(java -jar lib/jstestdriver/JsTestDriver.jar --browser open --port 9876) + desc 'Run bundled modules unit test suite (single run)' + task :modules, :browsers, :misc_options do |t, args| + start_testacular('testacular-modules.conf.js', true, args[:browsers], args[:misc_options]) end - desc 'Run JavaScript tests against the server' - task :test do - sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all) - end + desc 'Run e2e test suite (single run)' + task :e2e, :browsers, :misc_options do |t, args| + start_testacular('testacular-e2e.conf.js', true, args[:browsers], args[:misc_options]) + end end -desc 'Run JavaScript tests' -task :test do - sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all --browser open --port 9876) -end - +namespace :autotest do -desc 'Lint' -task :lint do - out = %x(lib/jsl/jsl -conf lib/jsl/jsl.default.conf) - print out -end + desc 'Run jqLite-based unit test suite (autowatch)' + task :jqlite, :browsers, :misc_options do |t, args| + start_testacular('testacular-jqlite.conf.js', false, args[:browsers], args[:misc_options]) + end -desc 'push_angularjs' -task :push_angularjs => :compile do - sh %(cat angularjs.ftp | ftp -N angularjs.netrc angularjs.org) + desc 'Run jQuery-based unit test suite (autowatch)' + task :jquery, :browsers, :misc_options do |t, args| + start_testacular('testacular-jquery.conf.js', false, args[:browsers], args[:misc_options]) + end end @@ -271,11 +268,14 @@ end def closure_compile(filename) - puts "Compiling #{filename} ..." + puts "Minifying #{filename} ..." min_path = path_to(filename.gsub(/\.js$/, '.min.js')) - %x(java -jar lib/closure-compiler/compiler.jar \ + %x(java \ + -client \ + -d32 \ + -jar lib/closure-compiler/compiler.jar \ --compilation_level SIMPLE_OPTIMIZATIONS \ --language_in ECMASCRIPT5_STRICT \ --js #{path_to(filename)} \ @@ -289,7 +289,7 @@ end def concat_file(filename, deps, footer='') - puts "Building #{filename} ..." + puts "Creating #{filename} ..." File.open(path_to(filename), 'w') do |f| concat = 'cat ' + deps.flatten.join(' ') @@ -326,3 +326,12 @@ def rewrite_file(filename) f.write content end end + + +def start_testacular(config, singleRun, browsers, misc_options) + sh "./node_modules/testacular/bin/testacular start " + + "#{config} " + + "#{'--single-run=true' if singleRun} " + + "#{'--browsers=' + browsers.gsub('+', ',') if browsers} " + + "#{(misc_options || '').gsub('+', ',')}" +end diff --git a/angularFiles.js b/angularFiles.js index 70502b044712..02bdf3a1d062 100644 --- a/angularFiles.js +++ b/angularFiles.js @@ -196,36 +196,30 @@ angularFiles = { ] }; -// Execute only in slim-jim -if (typeof JASMINE_ADAPTER !== 'undefined') { - // Testacular config - var mergedFiles = []; - angularFiles.jstd.forEach(function(file) { - // replace @ref - var match = file.match(/^\@(.*)/); - if (match) { - var deps = angularFiles[match[1]]; - if (!deps) { - console.log('No dependency:' + file) +if (exports) { + exports.files = angularFiles + exports.mergeFiles = function mergeFiles() { + var files = []; + + [].splice.call(arguments, 0).forEach(function(file) { + if (file.match(/testacular/)) { + files.push(file); + } else { + angularFiles[file].forEach(function(f) { + // replace @ref + var match = f.match(/^\@(.*)/); + if (match) { + var deps = angularFiles[match[1]]; + files = files.concat(deps); + } else { + if (!/jstd|jasmine/.test(f)) { //TODO(i): remove once we don't have jstd/jasmine in repo + files.push(f); + } + } + }); } - mergedFiles = mergedFiles.concat(deps); - } else { - mergedFiles.push(file); - } - }); + }); - files = [JASMINE, JASMINE_ADAPTER]; - - mergedFiles.forEach(function(file){ - if (/jstd|jasmine/.test(file)) return; - files.push(file); - }); - - - exclude = angularFiles.jstdExclude; - - autoWatch = true; - autoWatchInterval = 1; - logLevel = LOG_INFO; - logColors = true; + return files; + } } diff --git a/angularjs.ftp b/angularjs.ftp deleted file mode 100644 index dbe1039761ba..000000000000 --- a/angularjs.ftp +++ /dev/null @@ -1,5 +0,0 @@ -bin -cd angularjs.org/ng -put angular-debug.js js/angular-debug.js -put angular-minified.js js/angular-minified.js -put angular-scenario.js js/angular-scenario.js diff --git a/check-size.sh b/check-size.sh index 0ae5521d04db..fd46d0c9227b 100755 --- a/check-size.sh +++ b/check-size.sh @@ -1,5 +1,5 @@ #!/bin/bash -rake compile +rake minify gzip -c < build/angular.min.js > build/angular.min.js.gzip ls -l build/angular.min.* diff --git a/docs/content/api/index.ngdoc b/docs/content/api/index.ngdoc index 88e354f5d9f3..d0ab64e63510 100644 --- a/docs/content/api/index.ngdoc +++ b/docs/content/api/index.ngdoc @@ -2,6 +2,6 @@ @name API Reference @description -Use the API Refference documentation when you need more information about a specific feature. Check out -{@link guide/ Developer Guide} for AngularJS concepts. If you are new to AngularJS we recomend the +Use the API Reference documentation when you need more information about a specific feature. Check out +{@link guide/ Developer Guide} for AngularJS concepts. If you are new to AngularJS we recommend the {@link tutorial/ Tutorial}. diff --git a/docs/content/guide/bootstrap.ngdoc b/docs/content/guide/bootstrap.ngdoc index e4ead9231e3f..3be24bb56281 100644 --- a/docs/content/guide/bootstrap.ngdoc +++ b/docs/content/guide/bootstrap.ngdoc @@ -24,8 +24,8 @@ initialization. - * Place the `script` tag at the buttom of the page. Placing script tags at the end of the page - improves app load time becouse the HTML loading is not blocked by loading of the `angular.js` + * Place the `script` tag at the bottom of the page. Placing script tags at the end of the page + improves app load time because the HTML loading is not blocked by loading of the `angular.js` script. You can get the latest bits from {@link http://code.angularjs.org}. Please don't link your production code to this URL, as it will expose a security hole on your site. For experimental development linking to our site is fine. @@ -34,12 +34,12 @@ initialization. * Choose: `angular-[version].min.js` for a compressed and obfuscated file, suitable for use in production. * Place `ng-app` to the root of your application, typically on the `` tag if you want - anugular to auto-bootstrap your application. + angular to auto-bootstrap your application. * If you choose to use the old style directive syntax `ng:` then include xml-namespace in `html` - to make IE happy. (This is here for historical resons, and we no longer recomend use of + to make IE happy. (This is here for historical reasons, and we no longer recommend use of `ng:`.) diff --git a/docs/content/guide/compiler.ngdoc b/docs/content/guide/compiler.ngdoc index 9c86b977ae5d..ef7feef0c7c4 100644 --- a/docs/content/guide/compiler.ngdoc +++ b/docs/content/guide/compiler.ngdoc @@ -7,7 +7,7 @@ Angular's {@link api/ng.$compile HTML compiler} allows the developer to teach the browser new HTML syntax. The compiler allows you to attach behavior to any HTML element or attribute and even create new HTML element or attributes with custom behavior. Angular calls these behavior -extensions {@link api/ng.$compileProvider.directive directives}. +extensions {@link api/ng.$compileProvider#directive directives}. HTML has a lot of constructs for formatting the HTML for static documents in declarative fashion. For example if something needs to be centered, there is no need to provide instructions to the @@ -60,7 +60,7 @@ api/ng.directive:ngBind `ng-bind`} directive. Directive is just a function which executes when the compiler encounters it in the DOM. See {@link -api/ng.$compileProvider.directive directive API} for in depth documentation on how +api/ng.$compileProvider#directive directive API} for in-depth documentation on how to write directives. Here is a directive which makes any element draggable. Notice the `draggable` attribute on the diff --git a/docs/content/guide/concepts.ngdoc b/docs/content/guide/concepts.ngdoc new file mode 100644 index 000000000000..438d814edf4e --- /dev/null +++ b/docs/content/guide/concepts.ngdoc @@ -0,0 +1,467 @@ +@ngdoc overview +@name Conceptual Overview +@description + +# Overview + +This document gives a quick overview of the main angular components and how they work together. +These are: + + * {@link concepts#startup startup} - bring up hello world + * {@link concepts#runtime runtime} - overview of angular runtime + * {@link concepts#scope scope} - the glue between the view and the controller + * {@link concepts#controller controller} - application behavior + * {@link concepts#model model} - your application data + * {@link concepts#view view} - what the user sees + * {@link concepts#directives directives} - extend HTML vocabulary + * {@link concepts#filters filters} - format the data in user locale + * {@link concepts#injector injector} - assembles your application + * {@link concepts#module module} - configures the injector + * {@link concepts#angular_namespace `$`} - angular namespace + + +# Startup + +This is how we get the ball rolling (refer to the diagram and example below): + + + + 1. Browser loads the HTML and parses it into a DOM + 2. Browser loads `angular.js` script + 3. Angular waits for `DOMContentLoaded` event + 4. Angular looks for {@link api/ng.directive:ngApp ng-app} + {@link guide/directive directive}, which designates application boundary + 5. {@link guide/module Module} specified in {@link + api/ng.directive:ngApp ng-app} (if any) is used to configure + the {@link api/AUTO.$injector $injector} + 6. {@link api/AUTO.$injector $injector} is used to create the {@link + api/ng.$compile $compile} service as well as {@link + api/ng.$rootScope $rootScope} + 7. {@link api/ng.$compile $compile} service is used to compile the DOM and link + it with {@link api/ng.$rootScope $rootScope} + 8. {@link api/ng.directive:ngInit ng-init} {@link + guide/directive directive} assigns `World` to the `name` property on the {@link guide/scope + scope} + 9. The `{{name}}` {@link api/ng.$interpolate interpolates} the expression to + `Hello World!` + +
+
+ + +

Hello {{name}}!

+
+
+ + + +# Runtime + + + +The diagram and the example below describe how Angular interacts with browser's event loop. + + 1. Browsers event-loop waits for an event to arrive. Event is a user interactions, timer event, + or network event (response from a server). + 2. The events callback gets executed. This enters the JavaScript context. The callback can + modify the DOM structure. + 3. Once the callback finishes execution, the browser leaves the JavaScript context and + re-renders the view based on DOM changes. + +Angular modifies the normal JavaScript flow by providing it's own event processing loop. This +splits the JavaScript into classical and Angular execution context. Only operations which are +applied in Angular execution context will benefit from angular data-binding, exception handling, +property watching, etc... Use $apply() to enter Angular execution context from JavaScript. Keep in +mind that in most places (controllers, services) the $apply has already been called for you by the +directive which is handling the event. The need to call $apply is reserved only when +implementing custom event callbacks, or when working with a third-party library callbacks. + + 1. Enter Angular execution context by calling {@link guide/scope scope}`.`{@link + api/ng.$rootScope.Scope#$apply $apply}`(stimulusFn)`. Where `stimulusFn` is + the work you wish to do in Angular execution context. + 2. Angular executes the `stimulusFn()`, which typically modifies application state. + 3. Angular enters the {@link api/ng.$rootScope.Scope#$digest $digest} loop. The + loop is made up of two smaller loops which process {@link + api/ng.$rootScope.Scope#$evalAsync $evalAsync} queue and the {@link + api/ng.$rootScope.Scope#$watch $watch} list. The {@link + api/ng.$rootScope.Scope#$digest $digest} loop keeps iterating until the model + stabilizes, which means that the {@link api/ng.$rootScope.Scope#$evalAsync + $evalAsync} queue is empty and the {@link api/ng.$rootScope.Scope#$watch + $watch} list does not detect any changes. + 4. The {@link api/ng.$rootScope.Scope#$evalAsync $evalAsync} queue is used to + schedule work which needs to occur outside of current stack frame, but before the browser + view render. This is usually done with `setTimeout(0)`, but the `setTimeout(0)` approach + suffers from slowness and may cause view flickering since the browser renders the view after + each event. + 5. The {@link api/ng.$rootScope.Scope#$watch $watch} list is a set of expressions + which may have changed since last iteration. If a change is detected then the `$watch` + function is called which typically updates the DOM with the new value. + 6. Once Angular {@link api/ng.$rootScope.Scope#$digest $digest} loop finishes + the execution leaves the Angular and JavaScript context. This is followed by the browser + re-rendering the DOM to reflect any changes. + + +Here is the explanation of how the `Hello wold` example achieves the data-binding effect when the +user enters text into the text field. + + 1. During the compilation phase: + 1. the {@link api/ng.directive:ngModel ng-model} and {@link + api/ng.directive:input input} {@link guide/directive + directive} set up a `keydown` listener on the `` control. + 2. the {@link api/ng.$interpolate {{name}} } interpolation + sets up a {@link api/ng.$rootScope.Scope#$watch $watch} to be notified of + `name` changes. + 2. During the runtime phase: + 1. Pressing an '`X`' key causes the browser to emit a `keydown` event on the input control. + 2. The {@link api/ng.directive:input input} directive + captures the change to the input's value and calls {@link + api/ng.$rootScope.Scope#$apply $apply}`("name = 'X';")` to update the + application model inside the Angular execution context. + 3. Angular applies the `name = 'X';` to the model. + 4. The {@link api/ng.$rootScope.Scope#$digest $digest} loop begins + 5. The {@link api/ng.$rootScope.Scope#$watch $watch} list detects a change + on the `name` property and notifies the {@link api/ng.$interpolate + {{name}} } interpolation, which in turn updates the DOM. + 6. Angular exits the execution context, which in turn exits the `keydown` event and with it + the JavaScript execution context. + 7. The browser re-renders the view with update text. + +
+
+ + + +

Hello {{name}}!

+
+
+ + +#Scope + +The {@link guide/scope scope} is responsible for detecting changes to the model section and +provides the execution context for expressions. The scopes are nested in a hierarchical structure +which closely follow the DOM structure. (See individual directive documentation to see which +directives cause a creation of new scopes.) + +The following example demonstrates how `name` {@link guide/expression expression} will evaluate +into different value depending on which scope it is evaluated in. The example is followed by +a diagram depicting the scope boundaries. + +
+
+
+ + +
+ Hello {{name}}! +
+
+
    +
  1. {{name}}
  2. +
+
+
+ + function GreetCtrl($scope) { + $scope.name = 'World'; + } + + function ListCtrl($scope) { + $scope.names = ['Igor', 'Misko', 'Vojta']; + } + + + .show-scope .doc-example-live.ng-scope, + .show-scope .doc-example-live .ng-scope { + border: 1px solid red; + margin: 3px; + } + +
+
+ + + + + +# Controller + + + +Controller is the code behind the view. Its job is to construct the model and publish it to the +view along with callback methods. The view is a projection of the scope onto the template (the +HTML). The scope is the glue which marshals the model to the view and forwards the events to the +controller. + +The separation of the controller and the view is important because: + + * The controller is written in JavaScript. JavaScript is imperative. Imperative is a good fit + for specifying application behavior. The controller should not contain any rendering + information (DOM references or HTML fragments). + * The view template is written in HTML. HTML is declarative. Declarative is a good fit for + specifying UI. The View should not contain any behavior. + * Since the controller is unaware of the view, there could be many views for the same + controller. This is important for re-skinning, device specific views (i.e. mobile vs desktop), + and testability. + +
+
+ + +
+ Hello {{name}}! + +
+
+ + function MyCtrl($scope) { + $scope.action = function() { + $scope.name = 'OK'; + } + + $scope.name = 'World'; + } + +
+ + + +# Model + + + +The model is the data which is used merged with the template to produce the view. To be able to +render the model into the view, the model has to be referenceable from the scope. Unlike many +other frameworks Angular makes no restrictions or requirements an the model. There are no classes +to inherit from or special accessor methods for accessing or changing the model. The model can be +primitive, object hash, or a full object Type. In short the model is a plain JavaScript object. + + +
+
+ + + +# View + + + +The view is what the users sees. The view begins its life as a template, it is merged with the +model and finally rendered into the browser DOM. Angular takes a very different approach to +rendering the view, to most other templating systems. + + * **Others** - Most templating systems begin as an HTML string with special templating markup. + Often the template markup breaks the HTML syntax which means that the template can not be + edited by an HTML editor. The template string is then parsed by the template engine, and + merged with the data. The result of the merge is an HTML string. The HTML string is then + written to the browser using the `.innerHTML`, which causes the browser to render the HTML. + When the model changes the whole process needs to be repeated. The granularity of the template + is the granularity of the DOM updates. The key here is that the templating system manipulates + strings. + * **Angular** - Angular is different, since its templating system works on DOM objects not on + strings. The template is still written in HTML string, but it is HTML (not HTML with + template sprinkled in.) The browser parses the HTML into DOM, and the DOM becomes the input to + the template engine know as the {@link api/ng.$compile compiler}. The compiler + looks for {@link guide/directive directives} which in turn set up {@link + api/ng.$rootScope.Scope#$watch watches} on the model. The result is a + continuously updating view which does not need template model re-merging. Your model becomes + the single source-of-truth for your view. + +
+
+ + + +
+
+
+
list={{list}}

+
    +
  1. + {{item}} +
  2. +
+
+
+
+ + + +# Directives + +A directive is a behavior or DOM transformation which is triggered by a presence of an attribute, +element name, or a class name. A directive allows you to extend the HTML vocabulary in a +declarative fashion. Following is an example which enables data-binding for the `contenteditable` +in HTML. + + + + angular.module('directive', []).directive('contenteditable', function() { + return { + require: 'ngModel', + link: function(scope, elm, attrs, ctrl) { + // view -> model + elm.bind('blur', function() { + scope.$apply(function() { + ctrl.$setViewValue(elm.html()); + }); + }); + + // model -> view + ctrl.render = function(value) { + elm.html(value); + }; + + // load init value from DOM + ctrl.$setViewValue(elm.html()); + } + }; + }); + + +
Edit Me
+
model = {{content}}
+
+ + div[contentEditable] { + cursor: pointer; + background-color: #D0D0D0; + margin-bottom: 1em; + padding: 1em; + } + +
+ + +# Filters + +{@link api/ng.$filter Filters} perform data transformation roles. Typically +they are used in conjunction with the locale to format the data in locale specific output. +They are follow the spirit of UNIX filters and follow similar syntax `|` (pipe). + + + +
+ Number formatting: {{ 1234567890 | number }}
+ array filtering + {{ list | filter:predicate | json }} +
+
+
+ + + + +# Modules and the Injector + + + +An {@link api/AUTO.$injector injector} is a service locator. There is a single +{@link api/AUTO.$injector injector} per Angular {@link +api/ng.directive:ngApp application}. The {@link +api/AUTO.$injector injector} provides a way to look up an object instance by its +name. The injector keeps on internal cache of all objects so that repeated calls to get the same +object name result in the same instance. If the object does not exist, then the {@link +api/AUTO.$injector injector} asks the instance factory to create a new instance. + +A {@link api/angular.Module module} is a way to configure the injector's instance factory, known +as a {@link api/AUTO.$provide provider}. + +
+
+  // Create a module
+  var myModule = angular.module('myModule', [])
+
+  // Configure the injector
+  myModule.factory('serviceA', function() {
+    return {
+      // instead of {}, put your object creation here
+    };
+  });
+
+  // create an injector and configure it from 'myModule'
+  var $injector = angular.injector(['myModule']);
+
+  // retrieve an object from the injector by name
+  var serviceA = $injector.get('serviceA');
+
+  // always true because of instance cache
+  $injector.get('serviceA') === $injector.get('serviceA');
+
+ + +But the real magic of the {@link api/AUTO.$injector injector} is that it can be +used to {@link api/AUTO.$injector#invoke call} methods and {@link +api/AUTO.$injector#instantiate instantiate} types. This subtle feature is what +allows the methods and types to ask for their dependencies rather then to look for them. + +
+  // You write functions such as this one.
+  function doSomething(serviceA, serviceB) {
+    // do something here.
+  }
+
+  // Angular provides the injector for your application
+  var $injector = ...;
+
+  ///////////////////////////////////////////////
+  // the old-school way of getting dependencies.
+  var serviceA = $injector.get('serviceA');
+  var serviceB = $injector.get('serviceB');
+
+  // now call the function
+  doSomething(serviceA, serviceB);
+
+  ///////////////////////////////////////////////
+  // the cool way of getting dependencies.
+  // the $injector will supply the arguments to the function automatically
+  $injector.invoke(doSomething); // This is how the framework calls your functions
+
+ +Notice that the only thing you needed to write was the function, and list the dependencies in the +function arguments. When angular calls the function, it will use the {@link +api/AUTO.$injector#invoke call} which will automatically fill the function +arguments. + +Examine the `ClockCtrl` bellow, and notice how it list the dependencies in constructor. When the +{@link api/ng.directive:ngController ng-controller} instantiates +the controller it automatically provides the dependencies. There is no need to create +dependencies, look for dependencies, or even get a reference to the injector. + + + +
+ Current time is: {{ time.now }} +
+
+ + angular.module('timeExampleModule', []). + // Declare new object call time, + // which will be available for injection + factory('time', function($timeout) { + var time = {}; + + (function tick() { + time.now = new Date().toString(); + $timeout(tick, 1000); + })(); + return time; + }); + + // Notice that you can simply ask for time + // and it will be provided. No need to look for it. + function ClockCtrl($scope, time) { + $scope.time = time; + } + +
+ + + +# Angular Namespace + +To prevent accidental name collision, Angular prefixes names of objects which could potentially +collide with `$`. Please do not use the `$` prefix in your code as it may accidentally collide +with Angular code. diff --git a/docs/content/guide/dev_guide.e2e-testing.ngdoc b/docs/content/guide/dev_guide.e2e-testing.ngdoc index 7cb048414049..dd12e88add9c 100644 --- a/docs/content/guide/dev_guide.e2e-testing.ngdoc +++ b/docs/content/guide/dev_guide.e2e-testing.ngdoc @@ -122,7 +122,7 @@ Returns the current value of an input field with the given `name`. ## repeater(selector, label).count() Returns the number of rows in the repeater matching the given jQuery `selector`. The `label` is -used for test ouput. +used for test output. ## repeater(selector, label).row(index) Returns an array with the bindings in the row at the given `index` in the repeater matching the diff --git a/docs/content/guide/dev_guide.mvc.understanding_controller.ngdoc b/docs/content/guide/dev_guide.mvc.understanding_controller.ngdoc index df7db2e2cfdc..8188a0b1eba5 100644 --- a/docs/content/guide/dev_guide.mvc.understanding_controller.ngdoc +++ b/docs/content/guide/dev_guide.mvc.understanding_controller.ngdoc @@ -253,7 +253,7 @@ describe('state', function() { var mainCtrl = $controller(MainCtrl, {$scope: mainScope}); childScope = mainScope.$new(); var childCtrl = $controller(ChildCtrl, {$scope: childScope}); - babyScope = $rootScope.$new(); + babyScope = childCtrl.$new(); var babyCtrl = $controller(BabyCtrl, {$scope: babyScope}); })); diff --git a/docs/content/guide/dev_guide.services.$location.ngdoc b/docs/content/guide/dev_guide.services.$location.ngdoc index b13a47d172c1..8270b8989f26 100644 --- a/docs/content/guide/dev_guide.services.$location.ngdoc +++ b/docs/content/guide/dev_guide.services.$location.ngdoc @@ -23,13 +23,13 @@ changes to $location are reflected into the browser address bar. ## Comparing $location to window.location - +
- - - + + + @@ -165,13 +165,13 @@ facilitate the browser URL change and history management. -
window.location$location servicewindow.location$location service
+
- - - + + + @@ -331,11 +331,11 @@ to entry point of your application (e.g. index.html) ### Crawling your app -If you want your AJAX application to be indexed by web crawlers, you rill need to add the following +If you want your AJAX application to be indexed by web crawlers, you will need to add the following meta tag to the HEAD section of your document:
-This statement causes a crawler to request links with empty `_escaped_fragment_` parameter so that +This statement causes a crawler to request links with an empty `_escaped_fragment_` parameter so that your server can recognize the crawler and serve it HTML snapshots. For more information about this technique, see {@link http://code.google.com/web/ajaxcrawling/docs/specification.html Making AJAX Applications Crawlable}. @@ -543,69 +543,73 @@ then uses the information it obtains to compose hashbang URLs (such as ## Changes to your code -
Hashbang modeHTML5 modeHashbang modeHTML5 mode
- - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - + + + + +
Navigation inside the appChange to
$location.href = value
$location.hash = value
$location.update(value)
+
Navigation inside the appChange to
$location.href = value
$location.hash = value
$location.update(value)
$location.updateHash(value)
$location.path(path).search(search)
$location.hashPath = path$location.path(path)
$location.hashSearch = search$location.search(search)
Navigation outside the appUse lower level API
$location.href = value
$location.update(value)
$window.location.href = value
$location[protocol | host | port | path | search]$window.location[protocol | host | port | path | search]
Read accessChange to
$location.hashPath$location.path()
$location.hashSearch$location.search()
$location.href
$location.protocol
$location.host
$location.port
$location.path(path).search(search)
$location.hashPath = path$location.path(path)
$location.hashSearch = search$location.search(search)
Navigation outside the appUse lower level API
$location.href = value
$location.update(value)
$window.location.href = value
$location[protocol | host | port | path | search]$window.location[protocol | host | port | path | search]
Read accessChange to
$location.hashPath$location.path()
$location.hashSearch$location.search()
$location.href
$location.protocol
$location.host
$location.port
$location.hash
$location.absUrl()
$location.protocol()
$location.host()
$location.port()
$location.absUrl()
$location.protocol()
$location.host()
$location.port()
$location.path() + $location.search()
$location.path
$location.search
$window.location.path
$window.location.search
$location.path
$location.search
$window.location.path
$window.location.search
## Two-way binding to $location diff --git a/docs/content/guide/dev_guide.services.creating_services.ngdoc b/docs/content/guide/dev_guide.services.creating_services.ngdoc index 060ab38fc90b..355d3243ad09 100644 --- a/docs/content/guide/dev_guide.services.creating_services.ngdoc +++ b/docs/content/guide/dev_guide.services.creating_services.ngdoc @@ -2,12 +2,12 @@ @name Developer Guide: Angular Services: Creating Services @description -While angular offers several useful services, for any nontrivial application you'll find it useful +While Angular offers several useful services, for any nontrivial application you'll find it useful to write your own custom services. To do this you begin by registering a service factory function with a module either via the {@link api/angular.module Module#factory api} or directly via the {@link api/AUTO.$provide $provide} api inside of module config function. -All angular services participate in {@link di dependency injection (DI)} by registering +All Angular services participate in {@link di dependency injection (DI)} by registering themselves with Angular's DI system (injector) under a `name` (id) as well as by declaring dependencies which need to be provided for the factory function of the registered service. The ability to swap dependencies for mocks/stubs/dummies in tests allows for services to be highly @@ -76,17 +76,17 @@ angular.module('myModule', [], function($provide) { # Instantiating Angular Services -All services in Angular are instantiates services lazily, this means that a service will be created +All services in Angular are instantiated lazily. This means that a service will be created only when it is needed for instantiation of a service or an application component that depends on it. -In other words, angular won't instantiate lazy services unless they are requested directly or +In other words, Angular won't instantiate lazy services unless they are requested directly or indirectly by the application. # Services as singletons -Lastly, it is important to realize that all angular services are application singletons. This means -that there is only one instance of a given service per injector. Since angular is lethally allergic -to the global state, it is possible to create multiple injectors, each with its own instance of a +Lastly, it is important to realize that all Angular services are application singletons. This means +that there is only one instance of a given service per injector. Since Angular is lethally allergic +to global state, it is possible to create multiple injectors, each with its own instance of a given service, but that is rarely needed, except in tests where this property is crucially important. diff --git a/docs/content/guide/dev_guide.services.testing_services.ngdoc b/docs/content/guide/dev_guide.services.testing_services.ngdoc index d6e5e4cef0d3..6e0bbacebdc6 100644 --- a/docs/content/guide/dev_guide.services.testing_services.ngdoc +++ b/docs/content/guide/dev_guide.services.testing_services.ngdoc @@ -2,7 +2,7 @@ @name Developer Guide: Angular Services: Testing Angular Services @description -Following is a unit test for the service in the example in {@link +The following is a unit test for the 'notify' service in the 'Dependencies' example in {@link dev_guide.services.creating_services Creating Angular Services}. The unit test example uses Jasmine spy (mock) instead of a real browser alert. @@ -55,7 +55,7 @@ it('should clear messages after alert', function() { * {@link dev_guide.services.understanding_services Understanding Angular Services} * {@link dev_guide.services.creating_services Creating Angular Services} * {@link dev_guide.services.managing_dependencies Managing Service Dependencies} -* {@link dev_guide.services.injecting_controllers Injecting Services Into Conrollers} +* {@link dev_guide.services.injecting_controllers Injecting Services Into Controllers} ## Related API diff --git a/docs/content/guide/dev_guide.templates.css-styling.ngdoc b/docs/content/guide/dev_guide.templates.css-styling.ngdoc index f88ec6f31479..529c2398d373 100644 --- a/docs/content/guide/dev_guide.templates.css-styling.ngdoc +++ b/docs/content/guide/dev_guide.templates.css-styling.ngdoc @@ -9,7 +9,7 @@ Angular sets these CSS classes. It is up to your application to provide useful s * `ng-invalid`, `ng-valid` - **Usage:** angular applies this class to an input widget element if that element's input does - notpass validation. (see {@link api/ng.directive:input input} directive). + not pass validation. (see {@link api/ng.directive:input input} directive). * `ng-pristine`, `ng-dirty` - **Usage:** angular {@link api/ng.directive:input input} directive applies `ng-pristine` class diff --git a/docs/content/guide/dev_guide.templates.databinding.ngdoc b/docs/content/guide/dev_guide.templates.databinding.ngdoc index ebd9a1e6fb6d..396aa609654e 100644 --- a/docs/content/guide/dev_guide.templates.databinding.ngdoc +++ b/docs/content/guide/dev_guide.templates.databinding.ngdoc @@ -24,7 +24,7 @@ because first the template (which is the uncompiled HTML along with any addition directives) is compiled on the browser, and second, the compilation step produces a live view. We say live because any changes to the view are immediately reflected in the model, and any changes in the model are propagated to the view. This makes the model always the single-source-of-truth for -the application state, greatly simplifying the programing model for the developer. You can think of +the application state, greatly simplifying the programming model for the developer. You can think of the view as simply an instant projection of your model. Because the view is just a projection of the model, the controller is completely separated from the diff --git a/docs/content/guide/dev_guide.templates.filters.ngdoc b/docs/content/guide/dev_guide.templates.filters.ngdoc index 9456ad1821fe..4cd743a492c3 100644 --- a/docs/content/guide/dev_guide.templates.filters.ngdoc +++ b/docs/content/guide/dev_guide.templates.filters.ngdoc @@ -14,9 +14,6 @@ displaying it to the user. You can pass expressions through a chain of filters l The expression evaluator simply passes the value of name to {@link api/ng.filter:uppercase uppercase filter}. -In addition to formatting data, filters can also modify the DOM. This allows filters to handle -tasks such as conditionally applying CSS styles to filtered output. - ## Related Topics diff --git a/docs/content/guide/dev_guide.unit-testing.ngdoc b/docs/content/guide/dev_guide.unit-testing.ngdoc index fe3db075ecbb..fd0fe1dd8e71 100644 --- a/docs/content/guide/dev_guide.unit-testing.ngdoc +++ b/docs/content/guide/dev_guide.unit-testing.ngdoc @@ -16,7 +16,7 @@ this may seem obvious it usually is very difficult to be able to call an individ typical project. The reason is that the developers often time mix concerns, and they end up with a piece of code which does everything. It reads the data from XHR, it sorts it and then it manipulates the DOM. With angular we try to make it easy for you to do the right thing, and so we -provide dependency injection for your XHR (which you can mock out) and we crated abstraction which +provide dependency injection for your XHR (which you can mock out) and we created abstraction which allow you to sort your model without having to resort to manipulating the DOM. So that in the end, it is easy to write a sort function which sorts some data, so that your test can create a data set, apply the function, and assert that the resulting model is in the correct order. The test does not diff --git a/docs/content/guide/di.ngdoc b/docs/content/guide/di.ngdoc index d75d5b09aad5..ba54ff8d5798 100644 --- a/docs/content/guide/di.ngdoc +++ b/docs/content/guide/di.ngdoc @@ -165,7 +165,7 @@ For example: }); -Results in code bloat do to the need of temporary variable: +Results in code bloat due to the need of temporary variable:
   var greeterFactory = function(renamed$window) {
     ...;
diff --git a/docs/content/guide/directive.ngdoc b/docs/content/guide/directive.ngdoc
index 955ee09aa1be..062160a1f920 100644
--- a/docs/content/guide/directive.ngdoc
+++ b/docs/content/guide/directive.ngdoc
@@ -10,7 +10,7 @@ can be extended such that HTML can be turned into a declarative domain specific
 
 # Invoking directives from HTML
 
-Directives have camel cased names such as 'ngBind'. The directive can be invoked by translating
+Directives have camel cased names such as `ngBind`. The directive can be invoked by translating
 the camel case name into snake case with these special characters `:`, `-`, or `_`. Optionally the
 directive can be prefixed with `x-`, or `data-` to make it HTML validator compliant. Here is a
 list of some of the possible directive names: `ng:bind`, `ng-bind`, `ng_bind`, `x-ng-bind` and
@@ -63,7 +63,7 @@ api/ng.$rootScope.Scope#$digest digest} cycle. An example of interpolation is sh
 here:
 
 
-Hello {{username}}!
+Hello {{username}}!
 
# Compilation process, and directive matching @@ -74,7 +74,7 @@ Compilation of HTML happens in three phases: realize because the templates must be parsable HTML. This is in contrast to most templating systems that operate on strings, rather than on DOM elements. - 2. The compilation of the DOM is performed by the call to {@link api/ng.$compile + 2. The compilation of the DOM is performed by the call to the {@link api/ng.$compile $compile()} method. The method traverses the DOM and matches the directives. If a match is found it is added to the list of directives associated with the given DOM element. Once all directives for a given DOM element have been identified they are sorted by priority and their `compile()` @@ -109,8 +109,8 @@ Compilation of HTML happens in three phases: ## Reasons behind the compile/link separation -At this point you may wonder why is the compile process broken down to a compile and link phase. -To understand this, lets look at a real world example with repeater: +At this point you may wonder why the compile process is broken down to a compile and link phase. +To understand this, let's look at a real world example with repeater:
   Hello {{user}}, you have these actions:
@@ -125,7 +125,7 @@ The short answer is that compile and link separation is needed any time a change
 a change in DOM structure such as in repeaters.
 
 When the above example is compiled, the compiler visits every node and looks for directives. The
-`{{user}}` is an example of {@link api/ng.$interpolate interpolation} directive. {@link
+`{{user}}` is an example of an {@link api/ng.$interpolate interpolation} directive. {@link
 api/ng.directive:ngRepeat ngRepeat} is another directive. But {@link
 api/ng.directive:ngRepeat ngRepeat} has a dilemma. It needs to be
 able to quickly stamp out new `li`s for every `action` in `user.actions`. This means that it needs
@@ -138,16 +138,16 @@ But compiling on every `li` element clone would be slow, since the compilation r
 traverse the DOM tree and look for directives and execute them. If we put the compilation inside a
 repeater which needs to unroll 100 items we would quickly run into performance problems.
 
-The solution is to break the compilation process into two phases the compile phase where all of
+The solution is to break the compilation process into two phases; the compile phase where all of
 the directives are identified and sorted by priority, and a linking phase where any work which
 links a specific instance of the {@link api/ng.$rootScope.Scope scope} and the specific
 instance of an `li` is performed.
 
 {@link api/ng.directive:ngRepeat ngRepeat} works by preventing the
-compilation process form descending into `li` element. Instead the {@link
+compilation process form descending into the `li` element. Instead the {@link
 api/ng.directive:ngRepeat ngRepeat} directive compiles `li`
 separately. The result of of the `li` element compilation is a linking function which contains all
-of the directives contained in the `li` element ready to be attached to a specific clone of `li`
+of the directives contained in the `li` element, ready to be attached to a specific clone of the `li`
 element. At runtime the {@link api/ng.directive:ngRepeat ngRepeat}
 watches the expression and as items are added to the array it clones the `li` element, creates a
 new {@link api/ng.$rootScope.Scope scope} for the cloned `li` element and calls the
@@ -156,18 +156,18 @@ link function on the cloned `li`.
 Summary:
 
   * *compile function* - The compile function is relatively rare in directives, since most
-    directives are concerned with working with a specific DOM element instance rather then
+    directives are concerned with working with a specific DOM element instance rather than
     transforming the template DOM element. Any operation which can be shared among the instance of
     directives should be moved to the compile function for performance reasons.
 
-  * *link function* - It is rare for the directive not to have a link function. Link function
+  * *link function* - It is rare for the directive not to have a link function. A link function
     allows the directive to register listeners to the specific cloned DOM element instance as well
     as to copy content into the DOM from the scope.
 
 
 # Writing directives (short version)
 
-In this example we will build a directive which displays the current time.
+In this example we will build a directive that displays the current time.
 
 
   
@@ -211,17 +211,15 @@ In this example we will build a directive which displays the current time.
              $timeout.cancel(timeoutId);
            });
 
-           updateLater(); // kick of the UI update process.
+           updateLater(); // kick off the UI update process.
          }
        });
    
    
- Date format:
+ Date format:
Current time is:
- -
@@ -257,7 +255,7 @@ In most cases you will not need such fine control and so the above can be simpli different parts of this skeleton are explained in following sections. In this section we are interested only isomers of this skeleton. -The first step in simplyfing the code is to rely on the deafult values. Therefore the above can be +The first step in simplyfing the code is to rely on the default values. Therefore the above can be simplified as:
@@ -273,7 +271,7 @@ simplified as:
   });
 
-Most directives concern themselves only with instances not with template transformations allowing +Most directives concern themselves only with instances, not with template transformations, allowing further simplification:
@@ -290,7 +288,7 @@ further simplification:
 The factory method is responsible for creating the directive. It is invoked only once, when the
 {@link api/ng.$compile compiler} matches the directive for the first time. You can
 perform any initialization work here. The method is invoked using the {@link
-http://localhost:8000/build/docs/api/AUTO.$injector#invoke $injector.invoke} which
+api/AUTO.$injector#invoke $injector.invoke} which
 makes it injectable following all of the rules of injection annotation.
 
 ## Directive Definition Object
@@ -316,35 +314,37 @@ compiler}. The attributes are:
       apply for the root of the template since the root of the template always gets a new scope.
 
     * `{}` (object hash) - then a new 'isolate' scope is created. The 'isolate' scope differs from
-      normal scope that it does not prototypically inherit from the parent scope. This is useful
-      when creating reusable components, which should not accidentally read or modify data in
+      normal scope in that it does not prototypically inherit from the parent scope. This is useful
+      when creating reusable components, which should not accidentally read or modify data in the
       parent scope. 
The 'isolate' scope takes an object hash which defines a set of local scope properties derived from the parent scope. These local properties are useful for aliasing values for templates. Locals definition is a hash of local scope property to its source: - * `@` or `@attr` - bind a local scope property to the DOM attribute. The result is always a - string since DOM attributes are strings. If no `attr` name is specified then the local name - and attribute name are same. Given `` and widget definition + * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is + always a string since DOM attributes are strings. If no `attr` name is specified then the + attribute name is assumed to be the same as the local name. + Given `` and widget definition of `scope: { localName:'@myAttr' }`, then widget scope property `localName` will reflect the interpolated value of `hello {{name}}`. As the `name` attribute changes so will the `localName` property on the widget scope. The `name` is read from the parent scope (not component scope). - * `=` or `=expression` - set up bi-directional binding between a local scope property and the - parent scope property. If no `attr` name is specified then the local name and attribute - name are same. Given `` and widget definition of - `scope: { localModel:'=myAttr' }`, then widget scope property `localName` will reflect the + * `=` or `=attr` - set up bi-directional binding between a local scope property and the + parent scope property of name defined via the value of the `attr` attribute. If no `attr` + name is specified then the attribute name is assumed to be the same as the local name. + Given `` and widget definition of + `scope: { localModel:'=myAttr' }`, then widget scope property `localModel` will reflect the value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected in `localModel` and any changes in `localModel` will reflect in `parentModel`. * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope. - If no `attr` name is specified then the local name and attribute name are same. - Given `` and widget definition of - `scope: { localFn:'increment()' }`, then isolate scope property `localFn` will point to + If no `attr` name is specified then the attribute name is assumed to be the same as the + local name. Given `` and widget definition of + `scope: { localFn:'&myAttr' }`, then isolate scope property `localFn` will point to a function wrapper for the `increment()` expression. Often it's desirable to pass data from the isolate scope via an expression and to the parent scope, this can be done by passing a - map of local variable names and values into the expression wrapper fn. For example if the + map of local variable names and values into the expression wrapper fn. For example, if the expression is `increment(amount)` then we can specify the amount value by calling the `localFn` as `localFn({amount: 22})`. @@ -383,7 +383,7 @@ compiler}. The attributes are: the template loading is asynchronous the compilation/linking is suspended until the template is loaded. - * `replace` - if set to `true` then the template will replace the current element, rather then + * `replace` - if set to `true` then the template will replace the current element, rather than append the template to the element. * `transclude` - compile the content of the element and make it available to the directive. @@ -409,24 +409,24 @@ compiler}. The attributes are: function compile(tElement, tAttrs, transclude) { ... }
-Compile function deals with transforming the template DOM. Since most directives do not do -template transformation, it is not used often. Examples which require compile functions are -directives which transform template DOM such as {@link -api/ng.directive:ngRepeat ngRepeat} or load the contents -asynchronously such as {@link api/ng.directive:ngView ngView}. The -compile functions takes the following arguments. +The compile function deals with transforming the template DOM. Since most directives do not do +template transformation, it is not used often. Examples that require compile functions are +directives that transform template DOM, such as {@link +api/ng.directive:ngRepeat ngRepeat}, or load the contents +asynchronously, such as {@link api/ng.directive:ngView ngView}. The +compile function takes the following arguments. * `tElement` - template element - The element where the directive has been declared. It is safe to do template transformation on the element and child elements only. * `tAttrs` - template attributes - Normalized list of attributes declared on this element shared between all directive compile functions. See {@link - #Attributes Attributes} + guide/directive#Attributes Attributes}. * `transclude` - A transclude linking function: `function(scope, cloneLinkingFn)`. NOTE: The template instance and the link instance may not be the same objects if the template has -been cloned. For this reason it is not safe in the compile function to do anything other the DOM +been cloned. For this reason it is not safe in the compile function to do anything other than DOM transformation that applies to all DOM clones. Specifically, DOM listener registration should be done in a linking function rather than in a compile function. @@ -446,7 +446,7 @@ A compile function can have a return value which can be either a function or an function link(scope, iElement, iAttrs, controller) { ... }
-Link function is responsible for registering DOM listeners as well as updating the DOM. It is +The link function is responsible for registering DOM listeners as well as updating the DOM. It is executed after the template has been cloned. This is where most of the directive logic will be put. @@ -458,7 +458,8 @@ put. already been linked. * `iAttrs` - instance attributes - Normalized list of attributes declared on this element shared - between all directive linking functions. See {@link #Attributes Attributes} + between all directive linking functions. See {@link + guide/directive#Attributes Attributes}. * `controller` - a controller instance - A controller instance if at least one directive on the element defines a controller. The controller is shared among all the directives, which allows @@ -478,11 +479,11 @@ Executed after the child elements are linked. Safe to do DOM transformation in h ## Attributes -The attributes object - passed as a parameter in the link() or compile() functions - is a way of -accessing: +The {@link api/ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the +link() or compile() functions - is a way of accessing: * *normalized attribute names:* Since a directive such as 'ngBind' can be expressed in many ways - sucha s as 'ng:bind', or 'x-ng-bind', the attributes object allows for a normalize accessed to + such as 'ng:bind', or 'x-ng-bind', the attributes object allows for normalized accessed to the attributes. * *directive inter-communication:* All directives share the same instance of the attributes @@ -536,7 +537,7 @@ into the dialog. Here is an example of what the template definition for the `dialog` widget may look like.
-  
+

{{title}}

-We added a standard HTML `` tag and used angular's +We added a standard HTML `` tag and used Angular's {@link api/ng.filter:filter $filter} function to process the input for the -`ngRepeat` directive. +{@link api/ng.directive:ngRepeat ngRepeat} directive. This lets a user enter search criteria and immediately see the effects of their search on the phone list. This new code demonstrates the following: @@ -122,6 +122,11 @@ To run the end-to-end test, open one of the following in a new browser tab: `http://localhost:[port-number]/[context-path]/test/e2e/runner.html` * casual reader: {@link http://angular.github.com/angular-phonecat/step-3/test/e2e/runner.html} +Previously we've seen how Testacular can be used to execute unit tests. Well, it can also run the +end-to-end tests! Use `./scripts/e2e-test.sh` script for that. End-to-end tests are slow, so unlike +with unit tests, Testacular will exit after the test run and will not automatically rerun the test +suite on every file change. To rerun the test suite, execute the `e2e-test.sh` script again. + This test verifies that the search box and the repeater are correctly wired together. Notice how easy it is to write end-to-end tests in Angular. Although this example is for a simple test, it really is that easy to set up any functional, readable, end-to-end test. @@ -176,12 +181,14 @@ ngBindTemplate} directives, which are invisible to the user while the page is lo Refresh the browser tab with the end-to-end test runner to see the test fail. To make the test pass, edit the `index.html` template to add a `div` or `p` element with `id` `"status"` and content -with the `query` binding. +with the `query` binding, prefixed by "Current filter:". For instance: + +
Current filter: {{query}}
-* Add a `pause()` statement into an end-to-end test and rerun it. You'll see the runner pause; this -gives you the opportunity to explore the state of your application while it is displayed in the -browser. The app is live! You can change the search query to prove it. Notice how useful this is -for troubleshooting end-to-end tests. +* Add a `pause()` statement inside of an end-to-end test and rerun it. You'll see the runner pause; +this gives you the opportunity to explore the state of your application while it is displayed in +the browser. The app is live! You can change the search query to prove it. Notice how useful this +is for troubleshooting end-to-end tests. # Summary diff --git a/docs/content/tutorial/step_04.ngdoc b/docs/content/tutorial/step_04.ngdoc index 2542e21fdf02..0a6a74e5bcce 100644 --- a/docs/content/tutorial/step_04.ngdoc +++ b/docs/content/tutorial/step_04.ngdoc @@ -63,7 +63,7 @@ necessary! ## Controller -__`app/js/controller.js`:__ +__`app/js/controllers.js`:__
 function PhoneListCtrl($scope) {
   $scope.phones = [
@@ -103,7 +103,7 @@ to the model.
 The changes we made should be verified with both a unit test and an end-to-end test. Let's look at
 the unit test first.
 
-__`test/unit/controllerSpec.js`:__
+__`test/unit/controllersSpec.js`:__
 
 describe('PhoneCat controllers', function() {
 
@@ -134,13 +134,9 @@ The unit test now verifies that the default ordering property is set.
 We used Jasmine's API to extract the controller construction into a `beforeEach` block, which is
 shared by all tests in the parent `describe` block.
 
-To run the unit tests, once again execute the `./scripts/test.sh` script and you should see the
-following output.
+You should now see the following output in the Testacular tab:
 
-        Chrome: Runner reset.
-        ..
-        Total 2 tests (Passed: 2; Fails: 0; Errors: 0) (3.00 ms)
-          Chrome 19.0.1084.36 Mac OS: Run 2 tests (Passed: 2; Fails: 0; Errors 0) (3.00 ms)
+        Chrome 22.0: Executed 2 of 2 SUCCESS (0.021 secs / 0.001 secs)
 
 
 Let's turn our attention to the end-to-end test.
@@ -168,8 +164,8 @@ __`test/e2e/scenarios.js`:__
 
 The end-to-end test verifies that the ordering mechanism of the select box is working correctly.
 
-You can now refresh the browser tab with the end-to-end test runner to see the tests run, or you
-can see them running on {@link
+You can now rerun `./scripts/e2e-test.sh` or refresh the browser tab with the end-to-end test
+`runner.html` to see the tests run, or you can see them running on {@link
 http://angular.github.com/angular-phonecat/step-4/test/e2e/runner.html
 Angular's server}.
 
diff --git a/docs/content/tutorial/step_05.ngdoc b/docs/content/tutorial/step_05.ngdoc
index 805200782c00..0c960722d1f4 100644
--- a/docs/content/tutorial/step_05.ngdoc
+++ b/docs/content/tutorial/step_05.ngdoc
@@ -22,7 +22,7 @@ GitHub}:
 
 ## Data
 
-The `app/phones/phone.json` file in your project is a dataset that contains a larger list of phones
+The `app/phones/phones.json` file in your project is a dataset that contains a larger list of phones
 stored in the JSON format.
 
 Following is a sample of the file:
@@ -104,7 +104,7 @@ to avoid any possible naming collisions.
 Since angular infers the controller's dependencies from the names of arguments to the controller's
 constructor function, if you were to {@link http://en.wikipedia.org/wiki/Minification_(programming)
 minify} the JavaScript code for `PhoneListCtrl` controller, all of its function arguments would be
-minified as well, and the dependency injector would be able to identify services correctly.
+minified as well, and the dependency injector would not be able to identify services correctly.
 
 To overcome issues caused by minification, just assign an array with service identifier strings
 into the `$inject` property of the controller function, just like the last line in the snippet
@@ -164,8 +164,8 @@ isolated from the work done in other tests.
 
 * We created a new scope for our controller by calling `$rootScope.$new()`
 
-* We called `scope.$new(PhoneListCtrl)` to get Angular to create the child scope associated with
-the `PhoneListCtrl` controller.
+* We called the injected `$controller` function passing the `PhoneListCtrl` function and the created
+scope as parameters.
 
 Because our code now uses the `$http` service to fetch the phone list data in our controller, before
 we create the `PhoneListCtrl` child scope, we need to tell the testing harness to expect an
@@ -208,13 +208,10 @@ Finally, we verify that the default value of `orderProp` is set correctly:
 });
 
-To run the unit tests, execute the `./scripts/test.sh` script and you should see the following -output. +You should now see the following output in the Testacular tab: + + Chrome 22.0: Executed 2 of 2 SUCCESS (0.028 secs / 0.007 secs) - Chrome: Runner reset. - .. - Total 2 tests (Passed: 2; Fails: 0; Errors: 0) (3.00 ms) - Chrome 19.0.1084.36 Mac OS: Run 2 tests (Passed: 2; Fails: 0; Errors 0) (3.00 ms) # Experiments diff --git a/docs/content/tutorial/step_06.ngdoc b/docs/content/tutorial/step_06.ngdoc index 84c97babcad6..a4ca18ed50a4 100644 --- a/docs/content/tutorial/step_06.ngdoc +++ b/docs/content/tutorial/step_06.ngdoc @@ -65,7 +65,7 @@ api/ng.directive:ngSrc ngSrc} directive. That directive prevents the browser from treating the angular `{{ expression }}` markup literally, and initiating a request to invalid url `http://localhost:8000/app/{{phone.imageUrl}}`, which it would have done if we had only specified an attribute binding in a regular `src` attribute (``). -Using `ngSrc` (`ng-src`) prevents the browser from making an http request to an invalid location. +Using the `ngSrc` directive prevents the browser from making an http request to an invalid location. ## Test @@ -84,10 +84,11 @@ __`test/e2e/scenarios.js`__: We added a new end-to-end test to verify that the app is generating correct links to the phone views that we will implement in the upcoming steps. -You can now refresh the browser tab with the end-to-end test runner to see the tests run, or you -can see them running on {@link +You can now rerun `./scripts/e2e-test.sh` or refresh the browser tab with the end-to-end test +runner to see the tests run, or you can see them running on {@link http://angular.github.com/angular-phonecat/step-6/test/e2e/runner.html -angular's server}. +Angular's server}. + # Experiments @@ -96,11 +97,15 @@ or Chrome's Web Inspector, or inspecting the webserver access logs, confirm that making an extraneous request to `/app/%7B%7Bphone.imageUrl%7D%7D` (or `/app/{{phone.imageUrl}}`). + The issue here is that the browser will fire a request for that invalid image address as soon as +it hits the `img` tag, which is before Angular has a chance to evaluate the expression and inject +the valid address. + # Summary -Now that you have added phone images and links, go to {@link step_07 step 7} to learn about angular -layout templates and how angular makes it easy to create applications that have multiple views. +Now that you have added phone images and links, go to {@link step_07 step 7} to learn about Angular +layout templates and how Angular makes it easy to create applications that have multiple views.
    diff --git a/docs/content/tutorial/step_07.ngdoc b/docs/content/tutorial/step_07.ngdoc index a70d1287c3a7..820874ccb23c 100644 --- a/docs/content/tutorial/step_07.ngdoc +++ b/docs/content/tutorial/step_07.ngdoc @@ -19,7 +19,7 @@ detail page is displayed. The most important changes are listed below. You can see the full diff on {@link https://github.com/angular/angular-phonecat/compare/step-6...step-7 -GitHub}: +GitHub}. ## Multiple Views, Routing and Layout Template @@ -79,7 +79,7 @@ angular.module('phonecat', []).
    In order to configure our application with routes, we need to create a module for our application. -We call this module `phonecatApp` and using the `config` API we request the `$routeProvider` to be +We call this module `phonecat` and using the `config` API we request the `$routeProvider` to be injected into our config function and use `$routeProvider.when` API to define our routes. Note that during the injector configuration phase, the providers can be injected as well, but they @@ -114,14 +114,14 @@ directive: __`app/index.html`:__
     
    -
    +
     ...
     
    ## Controllers -__`app/js/controller.js`:__ +__`app/js/controllers.js`:__
     ...
     function PhoneDetailCtrl($scope, $routeParams) {
    @@ -140,11 +140,12 @@ route into the layout template, which makes it a perfect fit for our `index.html
     
     __`app/index.html`:__
     
    -
    +
     
     ...
       
       
    +  
     
     
     
    @@ -231,10 +232,10 @@ to various URLs and verify that the correct view was rendered.
     
    -You can now refresh the browser tab with the end-to-end test runner to see the tests run, or you -can see them running on {@link +You can now rerun `./scripts/e2e-test.sh` or refresh the browser tab with the end-to-end test +runner to see the tests run, or you can see them running on {@link http://angular.github.com/angular-phonecat/step-7/test/e2e/runner.html -angular's server}. +Angular's server}. # Experiments diff --git a/docs/content/tutorial/step_08.ngdoc b/docs/content/tutorial/step_08.ngdoc index 60330ad692e2..160ba19f8ee4 100644 --- a/docs/content/tutorial/step_08.ngdoc +++ b/docs/content/tutorial/step_08.ngdoc @@ -16,7 +16,7 @@ Now when you click on a phone on the list, the phone details page with phone-spe is displayed. To implement the phone details view we will use {@link api/ng.$http $http} to fetch -our data, and we'll flesh out the `phone-details.html` view template. +our data, and we'll flesh out the `phone-detail.html` view template. The most important changes are listed below. You can see the full diff on {@link https://github.com/angular/angular-phonecat/compare/step-7...step-8 @@ -59,7 +59,7 @@ show this data in the phone detail view. We'll expand the `PhoneDetailCtrl` by using the `$http` service to fetch the json files. This works the same way as the phone list controller. -__`app/js/controller.js`:__ +__`app/js/controllers.js`:__
     function PhoneDetailCtrl($scope, $routeParams, $http) {
       $http.get('phones/' + $routeParams.phoneId + '.json').success(function(data) {
    @@ -81,7 +81,7 @@ Note where we use the angular `{{expression}}` markup and `ngRepeat` to project
     our model into the view.
     
     
    -__`app/partials/phone-details.html`:__
    +__`app/partials/phone-detail.html`:__
     
     
     
    @@ -121,7 +121,7 @@ TODO!
     We wrote a new unit test that is similar to the one we wrote for the `PhoneListCtrl` controller in
     step 5.
     
    -__`test/unit/controllerSpec.js`:__
    +__`test/unit/controllersSpec.js`:__
     
     ...
       describe('PhoneDetailCtrl', function(){
    @@ -147,13 +147,9 @@ __`test/unit/controllerSpec.js`:__
     ...
     
    -To run the unit tests, execute the `./scripts/test.sh` script and you should see the following -output. +You should now see the following output in the Testacular tab: - Chrome: Runner reset. - ... - Total 3 tests (Passed: 3; Fails: 0; Errors: 0) (5.00 ms) - Chrome 19.0.1084.36 Mac OS: Run 3 tests (Passed: 3; Fails: 0; Errors 0) (5.00 ms) + Chrome 22.0: Executed 3 of 3 SUCCESS (0.039 secs / 0.012 secs) We also added a new end-to-end test that navigates to the Nexus S detail page and verifies that the @@ -177,10 +173,11 @@ __`test/e2e/scenarios.js`:__
    -You can now refresh the browser tab with the end-to-end test runner to see the tests run, or you -can see them running on {@link +You can now rerun `./scripts/e2e-test.sh` or refresh the browser tab with the end-to-end test +runner to see the tests run, or you can see them running on {@link http://angular.github.com/angular-phonecat/step-8/test/e2e/runner.html -angular's server}. +Angular's server}. + # Experiments diff --git a/docs/content/tutorial/step_09.ngdoc b/docs/content/tutorial/step_09.ngdoc index d81e17bc868c..dbc455c9413e 100644 --- a/docs/content/tutorial/step_09.ngdoc +++ b/docs/content/tutorial/step_09.ngdoc @@ -15,7 +15,7 @@ Navigate to one of the detail pages. In the previous step, the details page displayed either "true" or "false" to indicate whether certain phone features were present or not. We have used a custom filter to convert those text -strings into glyphs: ✓ for "true", and ✘ for "false". Let's see, what the filter code looks like. +strings into glyphs: ✓ for "true", and ✘ for "false". Let's see what the filter code looks like. The most important changes are listed below. You can see the full diff on {@link https://github.com/angular/angular-phonecat/compare/step-8...step-9 @@ -110,13 +110,9 @@ describe('filter', function() { Note that you need to configure our test injector with the `phonecatFilters` module before any of our filter tests execute. -To run the unit tests, execute the `./scripts/test.sh` script and you should see the following -output. +You should now see the following output in the Testacular tab: - Chrome: Runner reset. - .... - Total 4 tests (Passed: 4; Fails: 0; Errors: 0) (3.00 ms) - Chrome 19.0.1084.36 Mac OS: Run 4 tests (Passed: 4; Fails: 0; Errors 0) (3.00 ms) + Chrome 22.0: Executed 4 of 4 SUCCESS (0.034 secs / 0.012 secs) # Experiments diff --git a/docs/content/tutorial/step_10.ngdoc b/docs/content/tutorial/step_10.ngdoc index 4fa87a1f375f..245d951080d2 100644 --- a/docs/content/tutorial/step_10.ngdoc +++ b/docs/content/tutorial/step_10.ngdoc @@ -13,7 +13,7 @@ In this step, you will add a clickable phone image swapper to the phone details The phone details view displays one large image of the current phone and several smaller thumbnail images. It would be great if we could replace the large image with any of the thumbnails just by -clicking on the desired thumbnail image. Let's have a look at how we can do this with angular. +clicking on the desired thumbnail image. Let's have a look at how we can do this with Angular. The most important changes are listed below. You can see the full diff on {@link https://github.com/angular/angular-phonecat/compare/step-9...step-10 @@ -102,10 +102,10 @@ __`test/e2e/scenarios.js`:__ });
    -You can now refresh the browser tab with the end-to-end test runner to see the tests run, or you -can see them running on {@link +You can now rerun `./scripts/e2e-test.sh` or refresh the browser tab with the end-to-end test +runner to see the tests run, or you can see them running on {@link http://angular.github.com/angular-phonecat/step-8/test/e2e/runner.html -angular's server}. +Angular's server}. # Experiments diff --git a/docs/content/tutorial/step_11.ngdoc b/docs/content/tutorial/step_11.ngdoc index b881184b4caa..9ab28da3d08a 100644 --- a/docs/content/tutorial/step_11.ngdoc +++ b/docs/content/tutorial/step_11.ngdoc @@ -13,7 +13,7 @@ In this step, you will improve the way our app fetches data. The last improvement we will make to our app is to define a custom service that represents a {@link http://en.wikipedia.org/wiki/Representational_State_Transfer RESTful} client. Using this client we -can make xhr requests for data in an easier way, without having to deal with the lower-level {@link +can make XHR requests for data in an easier way, without having to deal with the lower-level {@link api/ng.$http $http} API, HTTP methods and URLs. The most important changes are listed below. You can see the full diff on {@link @@ -57,13 +57,22 @@ The {@link api/ngResource.$resource `$resource`} service makes it easy to create lines of code. This client can then be used in our application, instead of the lower-level {@link api/ng.$http $http} service. +__`app/js/app.js`.__ +
    +...
    +angular.module('phonecat', ['phonecatFilters', 'phonecatServices']).
    +...
    +
    + +We need to add 'phonecatServices' to 'phonecat' application's requires array. + ## Controller We simplified our sub-controllers (`PhoneListCtrl` and `PhoneDetailCtrl`) by factoring out the lower-level {@link api/ng.$http $http} service, replacing it with a new service called `Phone`. Angular's {@link api/ngResource.$resource `$resource`} service is easier to -use than `$http for interacting with data sources exposed as RESTful resources. It is also easier +use than `$http` for interacting with data sources exposed as RESTful resources. It is also easier now to understand what the code in our controllers is doing. __`app/js/controllers.js`.__ @@ -107,8 +116,8 @@ This is a simple statement that we want to query for all phones. An important thing to notice in the code above is that we don't pass any callback functions when invoking methods of our Phone service. Although it looks as if the result were returned synchronously, that is not the case at all. What is returned synchronously is a "future" — an -object, which will be filled with data when the xhr response returns. Because of the data-binding -in angular, we can use this future and bind it to our template. Then, when the data arrives, the +object, which will be filled with data when the XHR response returns. Because of the data-binding +in Angular, we can use this future and bind it to our template. Then, when the data arrives, the view will automatically update. Sometimes, relying on the future object and data-binding alone is not sufficient to do everything @@ -205,13 +214,9 @@ describe('PhoneCat controllers', function() { });
    -To run the unit tests, execute the `./scripts/test.sh` script and you should see the following -output. +You should now see the following output in the Testacular tab: - Chrome: Runner reset. - .... - Total 4 tests (Passed: 4; Fails: 0; Errors: 0) (3.00 ms) - Chrome 19.0.1084.36 Mac OS: Run 4 tests (Passed: 4; Fails: 0; Errors 0) (3.00 ms) + Chrome 22.0: Executed 4 of 4 SUCCESS (0.038 secs / 0.01 secs) # Summary diff --git a/docs/content/tutorial/the_end.ngdoc b/docs/content/tutorial/the_end.ngdoc index f62f4fdbe673..a573d39109df 100644 --- a/docs/content/tutorial/the_end.ngdoc +++ b/docs/content/tutorial/the_end.ngdoc @@ -3,7 +3,7 @@ @description Our application is now complete. Feel free to experiment with the code further, and jump back to -previous steps using the `git checkout` or `goto_step.sh` commands. +previous steps using the `git checkout` commandx. For more details and examples of the Angular concepts we touched on in this tutorial, see the {@link guide/ Developer Guide}. @@ -11,7 +11,7 @@ For more details and examples of the Angular concepts we touched on in this tuto For several more examples of code, see the {@link cookbook/ Cookbook}. When you are ready to start developing a project using Angular, we recommend that you bootstrap -your development with the {@link https://github.com/angular/angular-seed angular seed} project. +your development with the {@link https://github.com/angular/angular-seed angular-seed} project. We hope this tutorial was useful to you and that you learned enough about Angular to make you want to learn more. We especially hope you are inspired to go out and develop Angular web apps of your diff --git a/docs/img/guide/concepts-controller.png b/docs/img/guide/concepts-controller.png new file mode 100644 index 000000000000..91f3e76fce97 Binary files /dev/null and b/docs/img/guide/concepts-controller.png differ diff --git a/docs/img/guide/concepts-directive.png b/docs/img/guide/concepts-directive.png new file mode 100644 index 000000000000..b77d5f8ec98e Binary files /dev/null and b/docs/img/guide/concepts-directive.png differ diff --git a/docs/img/guide/concepts-model.png b/docs/img/guide/concepts-model.png new file mode 100644 index 000000000000..ac6db0234b74 Binary files /dev/null and b/docs/img/guide/concepts-model.png differ diff --git a/docs/img/guide/concepts-module-injector.png b/docs/img/guide/concepts-module-injector.png new file mode 100644 index 000000000000..31fcf84c626e Binary files /dev/null and b/docs/img/guide/concepts-module-injector.png differ diff --git a/docs/img/guide/concepts-runtime.png b/docs/img/guide/concepts-runtime.png new file mode 100644 index 000000000000..eededc2ab617 Binary files /dev/null and b/docs/img/guide/concepts-runtime.png differ diff --git a/docs/img/guide/concepts-scope.png b/docs/img/guide/concepts-scope.png new file mode 100644 index 000000000000..83ad8f8f4329 Binary files /dev/null and b/docs/img/guide/concepts-scope.png differ diff --git a/docs/img/guide/concepts-startup.png b/docs/img/guide/concepts-startup.png new file mode 100644 index 000000000000..b896a2b51697 Binary files /dev/null and b/docs/img/guide/concepts-startup.png differ diff --git a/docs/img/guide/concepts-view.png b/docs/img/guide/concepts-view.png new file mode 100644 index 000000000000..0222544bee8f Binary files /dev/null and b/docs/img/guide/concepts-view.png differ diff --git a/docs/src/example.js b/docs/src/example.js index c85e1d0e6fb6..7477b0a5055c 100644 --- a/docs/src/example.js +++ b/docs/src/example.js @@ -58,10 +58,10 @@ exports.Example.prototype.addSource = function(name, content) { }; exports.Example.prototype.toHtml = function() { - return '

    Source

    \n' + + return '

    Source

    \n' + this.toHtmlEdit() + this.toHtmlTabs() + - '

    Demo

    \n' + + '

    Demo

    \n' + this.toHtmlEmbed(); }; diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js index beaa35f0b355..a8ca8412e91f 100755 --- a/docs/src/gen-docs.js +++ b/docs/src/gen-docs.js @@ -12,8 +12,10 @@ process.on('uncaughtException', function(err) { var start = now(); var docs; -writer.makeDir('build/docs/syntaxhighlighter').then(function() { - console.log('Generating Angular Reference Documentation...'); +writer.makeDir('build/docs/', true).then(function() { + return writer.makeDir('build/docs/partials/'); +}).then(function() { + console.log('Generating AngularJS Reference Documentation...'); return reader.collect(); }).then(function generateHtmlDocPartials(docs_) { docs = docs_; @@ -40,8 +42,10 @@ writer.makeDir('build/docs/syntaxhighlighter').then(function() { function writeTheRest(writesFuture) { var metadata = ngdoc.metadata(docs); - writesFuture.push(writer.copyDir('img')); - writesFuture.push(writer.copyDir('font')); + writesFuture.push(writer.symlinkTemplate('css')); + writesFuture.push(writer.symlinkTemplate('font')); + writesFuture.push(writer.symlink('../../docs/img', 'build/docs/img')); + writesFuture.push(writer.symlinkTemplate('js')); var manifest = 'manifest="/build/docs/appcache.manifest"'; @@ -53,7 +57,7 @@ function writeTheRest(writesFuture) { writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq.html', - writer.replace, {'doc:manifest': manifest})); + writer.replace, {'doc:manifest': ''})); writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq-nocache.html', writer.replace, {'doc:manifest': ''})); @@ -65,27 +69,24 @@ function writeTheRest(writesFuture) { writesFuture.push(writer.copy('docs/src/templates/index.html', 'index-jq-debug.html', writer.replace, {'doc:manifest': ''})); - writesFuture.push(writer.copyTpl('offline.html')); - writesFuture.push(writer.copyTpl('docs-scenario.html')); - writesFuture.push(writer.copyTpl('js/jquery.min.js')); - writesFuture.push(writer.copyTpl('js/jquery.js')); + writesFuture.push(writer.symlinkTemplate('offline.html')); + + writesFuture.push(writer.copyTemplate('docs-scenario.html')); // will be rewritten, don't symlink + writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs))); - writesFuture.push(writer.output('js/docs-keywords.js', + writesFuture.push(writer.output('docs-keywords.js', ['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';'])); writesFuture.push(writer.output('sitemap.xml', new SiteMap(docs).render())); - writesFuture.push(writer.output('docs-scenario.js', ngdoc.scenarios(docs))); + writesFuture.push(writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n')); writesFuture.push(writer.output('appcache.manifest',appCache())); - writesFuture.push(writer.copyTpl('.htaccess')); - - writesFuture.push(writer.copy('docs/src/templates/js/docs.js', 'js/docs.js')); + writesFuture.push(writer.copyTemplate('.htaccess')); // will be rewritten, don't symlink - writesFuture.push(writer.copy('docs/src/templates/css/bootstrap.min.css', 'css/bootstrap.min.css')); - writesFuture.push(writer.copy('docs/src/templates/css/docs.css', 'css/docs.css')); - writesFuture.push(writer.copy('docs/src/templates/css/font-awesome.css', 'css/font-awesome.css')); + writesFuture.push(writer.symlinkTemplate('favicon.ico')); } function now() { return new Date().getTime(); } function noop() {}; + diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index ac6eb5f25de6..ae612a55e6ec 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -201,7 +201,7 @@ Doc.prototype = { } }); flush(); - this.shortName = this.name.split(/[\.:#]/).pop(); + this.shortName = this.name.split(/[\.:#]/).pop().trim(); this.id = this.id || // if we have an id just use it (((this.file||'').match(/.*\/([^\/]*)\.ngdoc/)||{})[1]) || // try to extract it from file name this.name; // default to name @@ -451,12 +451,16 @@ Doc.prototype = { dom.h('Usage', function() { dom.h('In HTML Template Binding', function() { dom.tag('code', function() { - dom.text('{{ '); - dom.text(self.shortName); - dom.text('_expression | '); - dom.text(self.shortName); - self.parameters(dom, ':', true); - dom.text(' }}'); + if (self.usage) { + dom.text(self.usage); + } else { + dom.text('{{ '); + dom.text(self.shortName); + dom.text('_expression | '); + dom.text(self.shortName); + self.parameters(dom, ':', true); + dom.text(' }}'); + } }); }); @@ -733,7 +737,7 @@ function metadata(docs){ for ( var i = 1; i < path.length; i++) { path.splice(i, 1); } - var shortName = path.pop(); + var shortName = path.pop().trim(); if (path.pop() == 'input') { shortName = 'input [' + shortName + ']'; diff --git a/docs/src/templates/.htaccess b/docs/src/templates/.htaccess index ad7b77522819..98c7b7954679 100644 --- a/docs/src/templates/.htaccess +++ b/docs/src/templates/.htaccess @@ -6,6 +6,7 @@ # # This file must be processed by Rake in order to replace %ANGULAR_VERSION% with the actual version. +Options -Indexes RewriteEngine on RewriteCond %{HTTP_COOKIE} ng-offline="NG_VERSION_FULL" RewriteRule appcache.manifest appcache-offline.manifest diff --git a/docs/src/templates/css/docs.css b/docs/src/templates/css/docs.css index 8359607e604d..53478e33036d 100644 --- a/docs/src/templates/css/docs.css +++ b/docs/src/templates/css/docs.css @@ -19,6 +19,11 @@ img.AngularJS-small { height: 1em; } + +.icon-cog { + line-height: 13px; +} + /* =============================== */ .form-search .dropdown-menu { @@ -140,6 +145,11 @@ ul.events > li > h3 { font-family: monospace; } +.center { + display: block; + margin: 2em auto; +} + .diagram { display: block; margin: 2em auto; @@ -170,3 +180,7 @@ ul.events > li > h3 { color: white; text-decoration: none; } + +.clear { + clear: both; +} diff --git a/docs/src/templates/docs-scenario.html b/docs/src/templates/docs-scenario.html index 49b9bf89db7c..b2e07115d29d 100644 --- a/docs/src/templates/docs-scenario.html +++ b/docs/src/templates/docs-scenario.html @@ -2,8 +2,42 @@ AngularJS Docs E2E Test Runner - - + diff --git a/docs/src/templates/favicon.ico b/docs/src/templates/favicon.ico new file mode 100644 index 000000000000..fe24a63a6ba4 Binary files /dev/null and b/docs/src/templates/favicon.ico differ diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index 226426878f44..625c449baf12 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -22,8 +22,13 @@ baseUrl = location.href.replace(rUrl, indexFile), jQuery = /index-jq[^\.]*\.html$/.test(baseUrl), debug = /index[^\.]*-debug\.html$/.test(baseUrl), + production = location.hostname === 'docs.angularjs.org', headEl = document.getElementsByTagName('head')[0], - sync = true; + sync = true, + angularVersion = { + current: '"NG_VERSION_FULL"', // rewrite during build + stable: '"NG_VERSION_STABLE"' + }; addTag('base', {href: baseUrl}); addTag('link', {rel: 'stylesheet', href: 'css/bootstrap.min.css', type: 'text/css'}); @@ -37,9 +42,23 @@ addTag('script', {src: path('angular-bootstrap.js') }, sync); addTag('script', {src: path('angular-bootstrap-prettify.js') }, sync); addTag('script', {src: 'js/docs.js'}, sync); - addTag('script', {src: 'js/docs-keywords.js'}, sync); + addTag('script', {src: 'docs-keywords.js'}, sync); function path(name) { + if (production) { + if (name.match(/^angular(-\w+)?\.js/) && !name.match(/bootstrap/)) { + name = '//ajax.googleapis.com/ajax/libs/angularjs/' + + angularVersion.stable + + '/' + + name.replace(/\.js$/, '.min.js'); + } else { + name = 'http://code.angularjs.org/' + + angularVersion.stable + + '/' + + name.replace(/\.js$/, '.min.js'); + } + return name; + } return '../' + name.replace(/\.js$/, debug ? '.js' : '.min.js'); } @@ -107,10 +126,10 @@ Learn @@ -120,10 +139,10 @@ Develop diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index de40db6403f8..387c01e20b12 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -30,9 +30,16 @@ docsApp.directive.code = function() { docsApp.directive.sourceEdit = function(getEmbeddedTemplate) { return { - template: '\n', + template: '
    ' + + '' + + ' Edit' + + '' + + '', scope: true, - controller: function($scope, $attrs, openJsFiddle) { + controller: function($scope, $attrs, openJsFiddle, openPlunkr) { var sources = { module: $attrs.sourceEdit, deps: read($attrs.sourceEditDeps), @@ -45,14 +52,19 @@ docsApp.directive.sourceEdit = function(getEmbeddedTemplate) { $scope.fiddle = function(e) { e.stopPropagation(); openJsFiddle(sources); - } + }; + $scope.plunkr = function(e) { + e.stopPropagation(); + openPlunkr(sources); + }; } } function read(text) { var files = []; angular.forEach(text ? text.split(' ') : [], function(refId) { - files.push({name: refId.split('-')[0], content: getEmbeddedTemplate(refId)}); + // refId is index.html-343, so we need to strip the unique ID when exporting the name + files.push({name: refId.replace(/-\d+$/, ''), content: getEmbeddedTemplate(refId)}); }); return files; } @@ -96,7 +108,7 @@ docsApp.directive.docTutorialReset = function() { '
      \n' + '
    1. Reset the workspace to step ' + step + '.

      ' + '
      ' + command + '
    2. \n' + - '
    3. Refresh your browser or check the app out on angular\'s server.

    4. \n' + + '
    5. Refresh your browser or check the app out on Angular\'s server.

    6. \n' + '
    \n' + '
    \n'; } @@ -111,8 +123,6 @@ docsApp.directive.docTutorialReset = function() { '
    \n' + tab('Git on Mac/Linux', 'git checkout -f step-' + step, 'gitUnix', step) + tab('Git on Windows', 'git checkout -f step-' + step, 'gitWin', step) + - tab('Snapshots on Mac/Linux', './goto_step.sh ' + step, 'snapshotUnix', step) + - tab('Snapshots on on Windows', './goto_step.bat ' + step, 'snapshotWin', step) + '
    \n'); } }; @@ -147,8 +157,47 @@ docsApp.serviceFactory.formPostData = function($document) { }; }; +docsApp.serviceFactory.openPlunkr = function(templateMerge, formPostData, angularUrls) { + return function(content) { + var allFiles = [].concat(content.js, content.css, content.html); + var indexHtmlContent = '\n' + + '\n' + + ' \n' + + ' \n' + + '{{scriptDeps}}\n' + + ' \n' + + ' \n\n' + + '{{indexContents}}' + + '\n\n \n' + + '\n'; + var scriptDeps = ''; + angular.forEach(content.deps, function(file) { + if (file.name !== 'angular.js') { + scriptDeps += ' \n' + } + }); + indexProp = { + angularJSUrl: angularUrls['angular.js'], + scriptDeps: scriptDeps, + indexContents: content.html[0].content + }; + var postData = {}; + angular.forEach(allFiles, function(file, index) { + if (file.content && file.name != 'index.html') { + postData['files[' + file.name + ']'] = file.content; + } + }); + + postData['files[index.html]'] = templateMerge(indexHtmlContent, indexProp); + + postData.description = 'AngularJS Example Plunkr'; + + formPostData('http://plnkr.co/edit/?p=preview', postData); + }; +}; + +docsApp.serviceFactory.openJsFiddle = function(templateMerge, formPostData, angularUrls) { -docsApp.serviceFactory.openJsFiddle = function(templateMerge, getEmbeddedTemplate, formPostData, angularUrls) { var HTML = '
    \n{{html:2}}
    ', CSS = ' \n' + '{{head:0}}