草庐IT

angularjs-sce

全部标签

javascript - AngularJS - 服务、工厂、过滤器等中的依赖注入(inject)

所以我有一些我想在我的Angular应用程序中使用的插件和库,并且(目前)我只是引用这些函数/方法,因为它们在99%的应用程序中都是以完全忽略依赖注入(inject)的方式引用的。我有(例如)javascript库“MomentJS”,它处理格式化和验证日期,我在我的整个应用程序中的Controller、服务和过滤器中都使用它。我学到的方法(使用AngularJS)是创建一个引用该函数(及其方法)的服务,并将该服务注入(inject)我的Controller,效果很好。问题是我真的需要在所有不同类型的组件中引用这个库,从服务到过滤器再到Controller和其他所有组件。所以,我想我的

javascript - AngularJS 中的 View 未更新

在事件回调中更新模型时更新模型属性对View没有影响,有什么办法解决这个问题吗?这是我的服务:angular.service('Channel',function(){varchannel=null;return{init:function(channelId,clientId){varthat=this;channel=newgoog.appengine.Channel(channelId);varsocket=channel.open();socket.onmessage=function(msg){varargs=eval(msg.data);that.publish(args[

javascript - AngularJS 中的 View 未更新

在事件回调中更新模型时更新模型属性对View没有影响,有什么办法解决这个问题吗?这是我的服务:angular.service('Channel',function(){varchannel=null;return{init:function(channelId,clientId){varthat=this;channel=newgoog.appengine.Channel(channelId);varsocket=channel.open();socket.onmessage=function(msg){varargs=eval(msg.data);that.publish(args[

javascript - AngularJS 指令 : Change $scope not reflected in UI

我正在尝试使用AngularJS制作一些自定义元素并将一些事件绑定(bind)到它,然后我注意到$scope.var在绑定(bind)函数中使用时不会更新UI。这是一个描述问题的简化示例:HTML:{{result}}ABJS:functionCtrl2($scope){$scope.result='ClickButtontochangethisstring';$scope.a=function(e){$scope.result='A';}$scope.b=function(e){$scope.result='B';}}varmod=angular.module('test',[]);

javascript - AngularJS 指令 : Change $scope not reflected in UI

我正在尝试使用AngularJS制作一些自定义元素并将一些事件绑定(bind)到它,然后我注意到$scope.var在绑定(bind)函数中使用时不会更新UI。这是一个描述问题的简化示例:HTML:{{result}}ABJS:functionCtrl2($scope){$scope.result='ClickButtontochangethisstring';$scope.a=function(e){$scope.result='A';}$scope.b=function(e){$scope.result='B';}}varmod=angular.module('test',[]);

javascript - 当用户离开页面时在 angularjs 中显示警报

我是一个angularjs新蜜蜂。我正在尝试编写一个验证,在用户尝试关闭浏览器窗口时提醒他。我的页面v1和v2上有2个链接。单击链接时会转到特定页面。这是重定向到v1和v2的代码angular.module('myApp',['myApp.filters','myApp.services','myApp.directives']).config(['$routeProvider',function($routeProvider){$routeProvider.when('/v1',{templateUrl:'pages/v_1.html',controller:MyCtrl1});$r

javascript - 当用户离开页面时在 angularjs 中显示警报

我是一个angularjs新蜜蜂。我正在尝试编写一个验证,在用户尝试关闭浏览器窗口时提醒他。我的页面v1和v2上有2个链接。单击链接时会转到特定页面。这是重定向到v1和v2的代码angular.module('myApp',['myApp.filters','myApp.services','myApp.directives']).config(['$routeProvider',function($routeProvider){$routeProvider.when('/v1',{templateUrl:'pages/v_1.html',controller:MyCtrl1});$r

javascript - 在 AngularJS 指令中查找子元素

我在一个指令中工作,但我在使用参数element按类名查找其子项时遇到问题。.directive("ngScrollList",function(){return{restrict:'AE',link:function($scope,element,attrs,controller){varscrollable=element.find('div.list-scrollable');...}};})我可以通过标签名找到它,但无法通过类名找到它,正如我在控制台中看到的那样:element.find('div')[​…​​,​…​​]element.find('div.list-scrol

javascript - 在 AngularJS 指令中查找子元素

我在一个指令中工作,但我在使用参数element按类名查找其子项时遇到问题。.directive("ngScrollList",function(){return{restrict:'AE',link:function($scope,element,attrs,controller){varscrollable=element.find('div.list-scrollable');...}};})我可以通过标签名找到它,但无法通过类名找到它,正如我在控制台中看到的那样:element.find('div')[​…​​,​…​​]element.find('div.list-scrol

javascript - 拖放可排序 ng :repeats in AngularJS?

在AngularJS中的ng-repeat元素上使用jQuery.sortable是否很容易?如果重新排序项目会自动将该排序传播回源数组,那就太棒了。恐怕这两个系统会打架。有更好的方法吗? 最佳答案 AngularUI有一个可排序指令,ClickHereforDemo代码位于ui-sortable,用法:{{item}}$scope.sorted=(event,ui)=>{console.log(ui.item[0].getAttribute('id'))} 关于javascript-拖