angular 音乐播放器-flash怎么播放flash

Flash 模拟试题及答案_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Flash 模拟试题及答案
&&flash试题及答案
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩43页未读,
定制HR最喜欢的简历
你可能喜欢用Flash、HTML5和Unity开发网页游戏的现实 - WEB前端 - 伯乐在线
& 用Flash、HTML5和Unity开发网页游戏的现实
& 来源: &&&&
今天对于全球的Flash开发者来说是黑暗的一天,因为Adobe宣布将不再对移动设备上的浏览器进行Flash技术支持。在这之前,Adobe刚刚宣布了公司范围内的大幅度裁员。尽管这似乎并不是什么严重的问题,但是这却又使“Flash hate wagon”开始转动。
首先,我只关心基于网页的游戏开发。因此,这篇文章只关注这个主题。这并不是一篇关于Flash和HTML5的争论文章, 也不是教你如何在移动设备上搭建应用程序。所以,这篇文章纯粹的是关注当今开发web game的现实。
我比较了Flash,HTML5,Unity,因为他们是当今唯一可行的web game开发平台。我列了10个主题来比较他们:
开发流程 – 用它来开发一个游戏有多容易?
平台稳定性 – 当你开始和结束开发游戏这段时间内,它会发生改变吗?
向后兼容性 – 用它开发的游戏10年后还能运行吗?
移动性 – 移动设备的支持
打包与分发 – 如何流通
安全性 – 代码和知识产权保护
货币化 – 如何运营赚钱
Facebook – 社交游戏的角度
多少人会玩你的游戏
3D支持 – Stage3D vs. WebGL vs. Unity
上述的方面我认为是所有游戏开发者在评估一个新的开发平台时都应该注意的。我希望这些建议对新老Flash开发者来说都会有所帮助。
1.开发流程
Flash:用Flash来开发游戏非常简单。因为关于它有无数的书籍,网站,教程,框架,视频和源代码。对于开发工具来说,Flex route是免费的,Flash IDE需要付费。Flash拥有通用且强大的矢量渲染功能,这意味这你创建的动画的文件格式会非常小。它全面支持音频和大多数的Adobe应用程序,例如在Flash IDE中嵌入Illustrator 和 Photoshop。而且Flash还有大量的内置功能。
HTML5:编辑器例如JetBrains 的Astella会使编程变的不那么痛苦。有一些优秀的调试工具使浏览器调试也非常简单。有许多关于HTML5游戏开发的书籍,网站,在线资源和示例程序。开发HTML5游戏的工具是免费,但是也有商业的工具,例如GameMaker HTML5 和Game Salad。如果你想让程序效率更高,并且你不怎么关注底层运行机制,你可以使用特定的的库类似ImpactJS。
Unity:有一个优秀的可视化编辑器,并且可以嵌入主流的3D应用程序中。基础版本是免费供家庭使用的。也可以在公司里使用,每年需要交纳不到100K $ 的费用。专业版本带有各种插件,价格在1500$上下。一旦你有了Unity,大量的教程和资源也随之提供,所以学习并不是问题。
2.平台稳定性
Flash:Flash是跨平台的,它不在乎你用的操作系统和浏览器是什么,不管你是破旧的IE或是最新的Chrome。只要你使用的平台上有Flash Player,对于体验来说都是一样的。Adobe每年都会发布一个新版本和许多现有版本的更新。
HTML5:HTML5一直处于变动中。基于此有2个副作用:第一,即便你什么都没有做,你的游戏仍然有潜在的崩溃可能。这是因为之前你已经升级或使用其他浏览器了。第二,你必须考虑多平台。在Chrome上可以运行只是第一步,你还必须处理IE,Firefox,Safari和各种操作系统。由此带来的维护成本也不能低估。另外,最大的技术挑战包括音频支持以及不一致的画布渲染速度等。
Unity: Unity的web player拥有和Flash一样的优势。Unity的插件也是跨平台的。Unity本身也会定期的发布新功能。
3.向后兼容性
Flash:10年前,用AS1制作的游戏仍旧可以在现在的Flash Player11上运行。向后兼容性十分出色。
HTML5:对于HTML5来说,比较向后兼容性有点不公平,因为它还在发展中。这意味着,如果它不符合W3C标准,就会被废弃。
Unity:Unity并不支持以前的插件,最开始我开期待它会像Flash一样,但似乎并不是这样。
Flash:直到今天前,我可以说,除了iOS平台,Flash插件对于移动平台的支持是伟大的。 但是Adobe官方宣布已经不再对移动设备上的Flash Player插件继续支持了,你可以认为它已经完全死了。当然你可以通过AIR来创建移动应用程序,但是这些不属于web game的范畴,所以我们不在此进行深入讨论。Stage3D对于移动的支持并不成熟,随着许多硬件厂商的合并,以及逐渐老化的AVM,对于Adobe的开发者来说是一场艰难的战争。种种迹象表明,在重建过程中,Adobe已经把Oliver Goldman从AIR团队中调到云项目。Oliver在AIR中是核心人物,至于结果怎样,只能仁者见仁了。
HTML5:HTML5对于移动的支持力度越来越强,iOS5上已经看到了性能的明显提升。当移动浏览器开始介入这些新特性,例如触摸事件和加速度的支持,我对于HTML5的前景逐渐看好。当然,你必须处理不同的屏幕分辨率和画面比例,但是这个问题不是只有HTML5有。
Unity:Unity并不支持移动浏览器上的插件。考虑到Unity的强项在于原生移动应用程序的编译,我能理解原因。
5.打包与分发
Flash:Flash的游戏最终都压缩成一个SWF文件。SWF文件可以简单地通过带有HTTP服务的网站进行传输。或者,它可以锁定到一个具体的URL上。Flash游戏的门户网站完全基于SWF文件的流动方式。SWF文件传播地越广,你挣的钱就越多。
HTML5:对于HTML5的游戏来说,没有跨平台或者统一的打包方式。那些最大的游戏门户网站都不允许开发者上传游戏。我认为是因为涉及到安全问题,它们不允许在站点上运行外来的JS程序。这就意味着传播HTML5游戏的唯一方式就是通过URL共享到一个目的站点,或者通过iFrame来嵌入。最终,是由开发者或赞助商来为给他们的游戏提供上传站点的主机费用买单。Flash传播游戏的方式是从站点来取出SWF文件,然后hosting这些SWF文件。这听起来不那么臭名招住,因为这的确是Flash挣钱的方式。门户网站可以使用带有沙箱参数设置的iFrame,但是这样做会阻止HTML5游戏需要使用的特性,例如本地存储和表单。
Unity:Unity和Flash类似,因为它也会最终创建出一个单一文件,然后上传到游戏门户网站,例如Kongregate。
Flash:SWF并不完美,但至少它能打包你所有的资源和代码到一个单一的文件,这就需要对它本身的技术很了解或者第三方的软件才能破解它。市场上有很多SWF保护服务和代码混淆软件,基本上可以防止随意的黑客和盗贼。
HTML5: JS代码可以混淆,但是不能被未加密的客户端加密。在内存中运行时,代码很容易被修改。图形和音频内容极容易被盗,可以通过Chrome或者Firefox的对象检查器,甚至通过浏览器的缓存文件夹。有人认为有一些保护HTML5资产的方式,并且认为Flash的资产一样容易被盗用。我不打算进入文件保护的辩论,我只想说,可以用来保护HTML5资产的方法都可以应用到Flash中。
Unity:和Flash类似。如果什么人有足够的决心来盗取它的资产,他会需要相当多的技术知识。
Flash:有许多很好的方式来挣钱,包括:游戏赞助,在游戏中的广告,与游戏门户网站的收入分成,广告分成,游戏中的交易,雇佣式游戏打工等等。我知道很多开发者完全不需要赞助商,只需要游戏和广告收入分成。网络中有大量为广告服务的API,只需要简单的上传你的游戏,就可以等到长期收入分成。
HTML5: 存在一些游戏中的广告服务,也可以把Google广告放在游戏中。我还没看到任何HTML5的游戏赞助市场或者收入分成交易。在游戏中的交易服务,比如Fortumo,已经存在和完善。
Unity:这里我不太懂,也许读者可以补充。
8.Facebook
Flash:Facebook上最流行的游戏都是用的Flash。The Sims Social每个月3600万的玩家使用的都是Flash。新的水果忍者同样使用Flash,并且会用到Flash 11的新特性。绝大部分的Zynga游戏也都使用Flash。之所以会这样,是因为Flash的受众,现有的技能(Flash开发者众多)和简单的开发流程。同时在Facebook上可以有很多方式来挣钱,因为它有大量的第三方服务和API接口。
HTML5: 我努力在Facebook上寻找最流行的纯HTML5游戏。当然肯定会有一些,因此,如果你找到了请帖链接。Zynga在2010年就收购了Dextrose,但是我还没看到什么结果。一些公司已经发布HTML5游戏到Facebook上,比如OMGPOP的Gem Rush,每日用户10人。但是Gem Rush只是用了HTML5的API,游戏本身还是Flash的!因此我的结论,目前为止,Facebook上最大的玩家群体还是使用Flash。
Unity:看上去Unity游戏在Facebook上也有一些赢利点。如UberStrike (每个月83万玩家) 和King’s Bounty(每个月2万玩家)。只要游戏内容足够吸引人,Facebook的用户也不方队安装Unity插件。
9.多少人会玩你的游戏
Flash:因为事实上,很多桌面用户都连接到互联网玩游戏,所以Flash的用户数量是巨大的。一个标准的Flash游戏在第一年通常有2-3百万次的访问量。好的Flash游戏当然次数更多。我们的游戏Home Sheep Home一上线就有每天1百万的访问量,在18个月内已经有1亿的访问量。这是一个惊人的数字。加上Facebook巨大的用户群,一定会有成百上千的用户在玩Flash游戏,玩家完全不是你的问题。
HTML5: 老实说,我无法找到任何相关数据,可能这个技术太新了,也没有用它做出来的好游戏。从技术上讲,可以说,潜在的用户可以有10亿,但是究竟事实上能有多少,开发者可以试试。
Unity:虽然Unity官方声明了玩家的数量,但是并没有第三方的统计。Kongregate上只有总共577000的访问量。而最好的Flash的游戏已经有2500万的访问量。事实上,排名前一百的Flash游戏没有低于250万的访问量。
Flash:Flash Play 11引入了Stage3D,它本质上是OpenGL ES 2.0。Adobe已经做了一个标准化的工作来实现它,但是也有一大堆注意事项。首先,游戏需要用wmode=direct来嵌入。而大多数的游戏门户网站还不支持,所以如果你的游戏放到一个不支持它的门户上,它根本不会运行3D硬件。其次,不支持GPU的黑名单很令人丧气。任何2009年前的驱动程序无法工作;最常见的英特尔GMAS(板载图形芯片)也无法工作。而在2007年,90%的个人电脑都用了因特尔GMAS,这是个真正的大问题。当然Adobe必须要划一条线,但是Flash的吸引力在于它无所谓运行在什么样的硬件上。如果你用了Stage3D,实际上你已经把巨大的潜在玩家抛弃了。所以必须非常小心的选择这条路,确保你能尽快的回收资本。
HTML5: 在这里我们谈WebGL。它和Stage3D在技术层面上有很多相似点,但是在很多关键领域有缺陷:不能全屏,没有鼠标捕获(Flash Player11.2支持),没有多重渲染目标,没有instanced drawing等等。在Autodesk的博客上有一片很好的文章说了这些问题。当然这些只是短期内的技术难点,并且最终将可以被克服。WebGL最大的问题在于Microsoft目前的立场是不支持它。Microsoft不是WebGL工作组的成员,而且不支持WebGL的任何格式。由于IE浏览器仍然有很大的占有率,所以这个不容忽视。
Unity:Unity当然支持3D。在有限的测试中,Unity结果完美。当然你需要安装Unity的浏览器插件。但是如果你知道你的游戏玩家足够,那么Unity仍然是目前最好的3D游戏解决方案。Unity宣称将支持导出Unity游戏成Flash格式,而且不会有Stage3D带来的GPU黑名单问题。我真想把钱给Unity,让他们能够在不远的将来能够把Unity游戏导出成WebGL格式。
提示:这篇译文翻译了大部分原文,后面还有有关“Adobe将会多久支持Flash播放器”和“Flash游戏开发人员该如何应对”的内容讨论。
可能感兴趣的话题
关于伯乐前端
伯乐前端分享Web前端开发,包括JavaScript,CSS和HTML5开发技术,前端相关的行业动态。
新浪微博:
推荐微信号
(加好友请注明来意)
– 好的话题、有启发的回复、值得信赖的圈子
– 分享和发现有价值的内容与观点
– 为IT单身男女服务的征婚传播平台
– 优秀的工具资源导航
– 翻译传播优秀的外文文章
– 国内外的精选文章
– UI,网页,交互和用户体验
– 专注iOS技术分享
– 专注Android技术分享
– JavaScript, HTML5, CSS
– 专注Java技术分享
– 专注Python技术分享
& 2018 伯乐在线在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
标签:至少1个,最多5个
class FlashPlayerController {
// 构造函数, 大部分的逻辑代码最好写在$onInit中, constructor 初始化一些变量
constructor($timeout) {
// 初始化完毕加载
$onInit($timeout) {
this.checkFlashPlayer = function () {
var hasFlashPlayer = 0; //判断是否安装了Flash Player
var flashPlayerVersion = 0; //Flash Player版本
if (document.all) {
var shockWaveFlash = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if (shockWaveFlash) {
hasFlashPlayer = 1;
flashPlayerVersion = parseInt(shockWaveFlash.GetVariable("$version").split(" ")[1].split(",")[0]);
} else if (navigator.plugins && navigator.plugins.length & 0) {
var shockWaveFlash = navigator.plugins["Shockwave Flash"];
if (shockWaveFlash) {
hasFlashPlayer = 1;
var descriptionInfo = shockWaveFlash.description.split(" ");
for (var i = 0; i & descriptionInfo. ++i) {
if (isNaN(parseInt(descriptionInfo[i]))) {
flashPlayerVersion = parseInt(descriptionInfo[i]);
return {hasFlashPlayer: hasFlashPlayer, flashPlayerVersion: flashPlayerVersion};
if (this.checkFlashPlayer().hasFlashPlayer) {
if (this.checkFlashPlayer().flashPlayerVersion &= 10) {
if (confirm("您的Flash Player版本过低,立即升级Flash Player版本?")) {
window.location.href = "http://get.adobe.com/cn/flashplayer/";
// alert("您安装了Flash Player,当前Flash Player版本号为:" + this.checkFlashPlayer().flashPlayerVersion + "。");
if (confirm("您没有安装Flash Player,立即安装?")) {
window.location.href = "http://get.adobe.com/cn/flashplayer/";
0 收藏&&|&&0
你可能感兴趣的文章
60 收藏,4.9k
分享到微博?
我要该,理由是:
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。angular-flash-alert - AngularJS Modules, Plugins and Directives
Flash message for angularjs
3 people use it
angular-flash
Add the Following code to the &head& of your document.
&link type=&text/css& rel=&stylesheet& href=&css/angular-flash.min.css& /&
// If you are using bootstrap v3 no need to include angular-flash.css
&script src=&http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js&&&/script&
&script src=&angular-flash.min.js&&&/script&
// Do not include both angular-flash.js and angular-flash.min.js
Add flash dependency to your module
var myApp = angular.module(&app&, [&flash&])
Include &div flash-message=&5000& &&/div& directive in your html template.
// 5000 milli-secs is the display duration.
// Flash alert will be automatically dismissed after 5000 milli-secs.
Inject the Flash factory in your controller
myApp.controller('demoCtrl', ['Flash', function(Flash) { ... }])
Flash.add('success', message, 'custom-class')
Flash alert types
Flash.pause();
// Pause flash auto dismiss.
Flash.dismiss()
// Dismiss the flash
Please enable JavaScript to view the
This page was last updated over 3 years ago.angular js Flashcards - Cram.com
Please sign in to share these flashcards. We'll bring you back here when you are done.
We weren't able to detect the audio language on your flashcards. Please select the correct language below.
Chinese, Pinyin
Chinese, Simplified
Chinese, Traditional
Japanese, Romaji
Math / Symbols
Azerbaijani
Belarusian
Chinese, Pinyin
Chinese, Simplified
Chinese, Traditional
Indonesian
Japanese, Romaji
Lithuanian
Luba-Kasai
Luxembourgish
Macedonian
Marshallese
Math / Symbols
Other / Unknown
Portuguese
Tohono O'odham
Vietnamese
Western Frisian
audio not yet available for this language
Chinese, Pinyin
Chinese, Simplified
Chinese, Traditional
Japanese, Romaji
Math / Symbols
Azerbaijani
Belarusian
Chinese, Pinyin
Chinese, Simplified
Chinese, Traditional
Indonesian
Japanese, Romaji
Lithuanian
Luba-Kasai
Luxembourgish
Macedonian
Marshallese
Math / Symbols
Other / Unknown
Portuguese
Tohono O'odham
Vietnamese
Western Frisian
audio not yet available for this language
Save changes
&&&angular js
Angular Js
Please sign in to add to folders.
You have created 2 folders. Please upgrade to Cram Premium to create hundreds of folders!
Toggle Off
Alphabetize
Toggle Off
Front First
Toggle Off
Both Sides
Toggle Off
How to study your flashcards.
Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key
Up/Down arrow keys: Flip the card between the front and back.down keyup key
H key: Show hint (3rd side).h key
A key: Read text to speech.a key
Play button
Play button
Click to flip
Click or Press Spacebar to Begin &
67 Cards in this Set
wy angular js ?
directive ?
it links the html code to javascript and tells html when to run or refer to JS code
what are modules?
explain each of the components of the following code --
1)angular - is a keyword for using angularjs2)module - used since we are creating a module3)store- name of the module4)[ ]= used to add dependencies
how will you include a module into the html code?
using ng-app, which is a directive
expressions
{{ ...... }}
what are controllers?
for example we have an object called gem and we need to sell it on out webpage ( html code) So controllers bridge this gap by connecting data with html
how to add controllers into the html code
how will you implement the price, description and reviews of a product of the module 'store' using expressions
how restricted is the scope of a controller ?
explain the relevance of ng-show directive below --
will show something if the boolean expression inside the ng-show quotes is true or valid
use of "ng-hide=store.product.soldOut" ?
if the product is sold out from the store, then ng-hide will hide the corresponding html element
what does ng-repeat do or is used for ?
used mainly for looping through an array
With more than one ng-app in an HTML document (an HTML page), are all of them automatically initialized?
No, only one app is automatically initialized. Others have to manually initialized.
Can angular applications (ng-app) be nested within each other?
how to manually start up the angular application?
using angular.bootstrap----
Can multiple angular applications be bootstrapped using same element
no Only one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document you must manually bootstrap them using angular.bootstrap instead. AngularJS applications cannot be nested within each other. -- http://docs.angularjs.org/api/ng.directive:ngApp
At framework level, how does Angular retrieve the matching elements for processing
1)Makes use of jqLite(element) function. 2)If jQuery is used, jQuery(element) is used by way of assigning jQuery to jqLite variable
Which API need to be invoked on the rootScope service to get the child scopes
Which angular function is used to wrap a raw DOM element or HTML string as a jQuery element?
angular.element
wat framework is ang js based on
angular js vs jquery
Query is great library for manipulating the DOM, providing better user experience with animations and effects. You can create website using jQuery but not a web application. jQuery is just a library to play around with HTML, where as AngularJS is a framework to build a dynamic web app as it supports two data binding, MVC, allow testability, templates and many more. Its like AngularJS like a toolbox and jQuery is just a tool.
adv of angular js
2 way data binding routing - which can make SPAs faster form validations done better
Is AngularJS is compatible with all modern browsers?
What is the bootstrapping in AngularJS?
Bootstrapping in AngularJS is nothing but just initializing, or starting, your Angular app. AngularJS supports automatic bootstrapping as well as manual way as well.
What are templates in AngularJS?
In Angular, templates are written with HTML that contains Angular-specific elements and attributes. Angular combines the template with information from the model and controller to render the dynamic view that a user sees in the browser. In other words, if your HTML page is having some Angular specific elements/attributes it becomes a template in AngularJS.
What are directives in AngularJS?
Directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS to attach a specified behavior to that DOM element or even transform the DOM element and its children. When AngularJS finds the directive at the time of rendering then it attaches the requested behavior to the DOM element. Angular comes with a set of these directives built-in, like ngBind, ngModel, and ngClass.
What are different type or classification of directives?
AngularJS directives can be classified in 4 different types .Element directives 1
Attribute directives 1
CSS class directives 1
Comment directives 1
What is the name of directive is used to bootstrap an angular app?
ng-app directive is used to auto-bootstrap an AngularJS application. The ng-appdirective defines the root element of the application and is typically present in the root element of the page - e.g. on the
Can AngularJS have multiple ng-app directives in a single page?
The answer is NO. Only one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application. If you have placed another ng-app directive then it will not be processed by AngularJS. You need to manually bootstrap the second app, instead of using second ng-app directive.
Can you bootstrap multiple angular applications on same element?
NO. If you try to do that then it will show an error "App Already Bootstrapped with this Element". This usually happens when you accidentally use both ng-app andangular.bootstrap to bootstrap an application. You can also get this error if you accidentally load AngularJS itself more than once.
In how many different ways, you can define a directive and what is the best practice?
Angular generally prefers camelCase for directives. But since HTML is not case-sensitive so it refers to directive in DOM in lower case form, delimited by dash (eg. ng-app). But when Angular complies then it normalize the directives.Below are example of valid directive declaration.* ng-model* ngModel* ng:model* ng_model* data-ng-model* x-ng-modelThe normalization process is as follows:1. Strip x- and data- from the front of the element/attributes.2. Convert the :, -, or _-delimited name to camelCase.The best practice to use dash-delimited (ng-model) or directly camelCase form (ngModel). If you are using HTML validation tool, then it is advised to use data- prefixed version. And it also answers another question which is "Difference between ng-* and data-ng-*".
binds html elements to if condition
ng-class and ng-src
used to assign css class and used to assign url image
ng-click : Click event to bind on HTML elements.
How Angular expressions are different from JavaScript expressions?
Angular expressions are like JavaScript expressions but there are few differences.* Context : In Angular, the expressions are evaluated against a scope object, while the JavaScript expressions are evaluated against the global window object.* Forgiving: In Angular expression evaluation is forgiving to null and undefined, while in JavaScript undefined properties generates TypeError or ReferenceError.* No Control Flow Statements: Loops, conditionals or exceptions cannot be used in an Angular expression.* No Comma And Void Operators: You cannot use , (comma) or void in an Angular expression. And You cannot create regular expressions in an Angular expression.
What is compilation process in Angular?
Once you have the markup, the AngularJS needs to attach the functionality. This process is called "compilation" in Angular. Compiling includes rendering of markup, replacing directives, attaching events to directives and creating a scope. The AngularJS has compiler service which traverses the DOM looking for attributes. The compilation process happens in two phases.* Compilation : traverse the DOM and collect all of the directives and creation of the linking function.* Linking: combine the directives with a scope and produce a live view. The linking function allows for the attaching of events and handling of scope. Any changes in the scope model are reflected in the view, and any user interactions with the view are reflected in the scope model.When you create a new directive, you can write compile and/or linking functions for it to attach your custom behavior.
scope object
AngularJS will invoke the controller with a $scope object.In AngularJS, $scope is the application object (the owner of application variables and functions).
root scope vs scope
Big Bird is {{ color }}.09
Grover is {{ color }}.11
The sun is {{ color }}.14
var app = angular.module('myApp', []).run(function($rootScope) {17
$rootScope.color = 'yellow';18
app.controller('GroverController', function($scope) {20
$scope.color = 'blue';21
app.controller('SunController', function($scope) {23
job of a controller
AngularJS controllers control the data of AngularJS applications.AngularJS controllers are regular JavaScript Objects.
$scope vs scope
Can we have nested controllers in AngularJS?
In case of nested controllers, does the $scope object shared across all controllers?
YES. The $scope object is shared across all controllers and it happens due to scope inheritance. Since the ng-controller directive creates a new child scope, we get a hierarchy of scopes that inherit from each other. So if we define a property on a parent scope, the child scope can manipulate the property. And if the property is not present in child scope, then parent scope property's value is used.
use of ng-bind
use of ng-model
ng-model vs ng-bind
Well, ng-bind directive is used only for display purpose or one way data binding Model -& View, where ng-model can be used for two way data binding Model -& View and View -& Model. Like in above example, when you change input type text, it is updating the model as well.
use of filters in angular js
Filters in Angular allows to select a subset of items using expression. Filters can be added to expressions and directives using a pipe character. Suppose we want to sort the names (previous question demo) and display the result, then we can use "orderBy" filter.
ng-click and ng-change
The best part about AngularJS directives are that they are self explanatory. Just looking at the name, one can imagine what should be use of the directive.ng-click directive allows you to specify custom behavior when an element is clicked. And ng-change directive is used to find out when any value gets changed for input, select control.
ng-submit directive is used to submit the form. But it only works when your form doesn't contain any action attribute. You can pass a function name to ng-submit and when form is submitted, the function will get called.1
$scope.apply and $scope.digest and $scope.watch methods
$scope.watch - it has 2 functions - the watch function watches over a value or a variable and and causes an operation if that value/or variable has changed through a listener function which is actually called in
The $scope.$digest() function iterates through all the watches in the $scope object, and its child $scopeobjects (if it has any). When $digest() iterates over the watches, it calls the value function for each watch. If the value returned by the value function is different than the value it returned the last time it was called, the listener function for
various prefixes for angular directives
what is the notion of 'isolate' scope object when creating a custom directive? How is it different from the normal scope object?
what are the different return types from compile function?
relationship between scope.apply and scope.digest?
4 steps for creating an angular route
wat are the 2 routeProvider methods u can use while implementing angular routes ?
how to use the date filter on a var d =
{{d |date:'MM/dd/yyyy @ h:mma'}}
how wud u implement ng-include?
advantages of using or implementing custom directives
how wud u build element directives?
how wud u build attribute directives?
how wud u build controller directives?
how can u implement the http service with the get method?
dependency injection
in order to fetch data from an API we need to use a service like the http service and then we use $http as a parameter in the controller so this wud be an example of
we can use many services in our controllers ( they can be passed as function arguments )
fetching data from json full example
what happens in this function below?
This example binds the $scope.data.time variable to an interpolation directive which merges the variable value into the HTML page. This binding creates a watch internally on the $scope.data.time variable.The example also contains two buttons. The first button has an ng-click listener attached to it. When that button is clicked the $scope.updateTime() function is called, and after that AngularJS calls$scope.$digest() so that data bindings are updated.The second button gets a standard JavaScript event listener attached to it from inside the controller function. When the second button is clicked that listener function is executed. As you can see, the listener functions for both buttons do almost the same, but when the second button's listener function is called, the data binding is not updated. That is because the $scope.$digest() is not called after the second button's event listener is executed. Thus, if you click the second button the time is updated in the $scope.data.time variable, but the new time is never displayed.
how will make the new time appear through this funxn ? what will u need to change ?
Instead of calling $digest() inside the button listener function you could also have used the $apply()function like this:document.getElementById("updateTimeButton")
.addEventListener('click', function() {
$scope.$apply(function() {
console.log("update time clicked");
$scope.data.time = new Date();
});});Notice how the $scope.$apply() function is called from inside the button event listener, and how the update of the $scope.data.time variable is performed inside the function passed as parameter to the $apply()function. When the $apply() function call finishes AngularJS calls $digest() internally, so all data bindings are updated.
Cram has partnered with the National Tutoring Association
Ready To Get Started?

我要回帖

更多关于 angular 视频播放 的文章

 

随机推荐