Tag: angularjs

检测未保存的更改并使用angularjs提醒用户

以下是目前的代码 <!doctype html> <html ng-app> <head> <script src="../../../1.1.2/angular.min.js"></script> <script type="text/javascript"> function Ctrl($scope) { var initial = {text: 'initial value'}; $scope.myModel = angular.copy(initial); $scope.revert = function() { $scope.myModel = angular.copy(initial); $scope.myForm.$setPristine(); } } </script> </head> <body> <form name="myForm" ng-controller="Ctrl"> myModel.text: <input name="input" ng-model="myModel.text"> <p>myModel.text = {{myModel.text}}</p> <p>$pristine = {{myForm.$pristine}}</p> <p>$dirty = {{myForm.$dirty}}</p> <button ng-click="revert()">Set pristine</button> </form> […]

量angular器/selenium“无法findchromedriver”(在Windows上)

我按照这个教程安装了量angular器,当我使用webdriver-manager更新时说: selenium standalone is up to date. chromedriver is up to date. 当我尝试运行量angular器testing时,它会说: C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\local.dp.js:42 throw new Error('Could not find chromedriver at ' + ^ Error: Could not find chromedriver at C:\Users\****\AppData\Roaming\npm\node_modules\protractor\selenium\chromedriver.exe at LocalDriverProvider.addDefaultBinaryLocs_ (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\local.dp.js:42:15) at LocalDriverProvider.setupEnv (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\local.dp.js:59:8) at Runner.run (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:308:31) at process.<anonymous> (C:\Users\****\AppData\Roaming\npm\node_modules\protractor\lib\runFromLauncher.js:32:14) at process.EventEmitter.emit (events.js:98:17) at handleMessage (child_process.js:318:10) at Pipe.channel.onread (child_process.js:345:11) [launcher] Runner Process […]

我应该使用Angular UI Bootstrap还是纯Bootstrap 3?

在编写的时候Angular UI Bootstrap基于Twitter Bootstrap 2,而最新版本是Bootstrap 3.如果我要在Angular.js中编写应用程序,我应该使用什么UI框架? Angular UI还是只是普通的Bootstrap? 那里有什么优点和缺点? 无论是长期还是短期。

angular度组件:没有模板replace选项?

看起来在新的AngularJS 1.5组件概念中没有“replace”选项(就像是指令一样)。 如果我想要表行 <TR>元素作为组件,你会build议什么? 在有效的HTML方面是不可能的? 真实的例子:mailBox组件里面有邮件组件。 通过标记邮箱组件是表,邮箱是tr。 <mail-box> <mail ng-repeat="mail in $ctrl.mails" mail="mail"></mail> <mail-box> UPD :关于指令的相关讨论 – 为什么在AngularJS中不推荐使用replace?

在设置模型值时,Angular会将奇怪的选项添加到select元素中

我有一个select元素定义如下: <select name="country_id" id="country_id" required="required" ng-model="newAddressForm.country_id"> <option value="">Select Country</option> <option ng-repeat="country in countries" value="{{country.id}}">{{country.name}}</option> </select> 所有工作正常,当我没有在包含这个select元素的指令中设置任何types的值。 但是当我做一些像newAddressForm.country_id = 98 ,而不是select值98的选项,Angular注入一个新的select元素的顶部,如下所示: <option value="? string:98 ?"></option> 是什么赋予了? 这是什么格式,为什么会发生这种情况? 请注意,如果我在指令中做了一个console.log(newAddressForm.country_id) ,我得到了一个正常的"98" ,这在生成的HTML中很奇怪。 编辑: 情况更新。 切换到使用ng-select ,但问题依然存在。 奇怪的元素不再出现,但是,现在还有另一个元素在顶部,只有一个问号? 作为价值,并没有标签。 就是从我所搜集的Angular的"none selected"选项。 但我仍然不明白为什么它不会select我告诉它select的选项。 newAddressForm.country_id = 98仍然没有结果。 这是为什么?

使用AngularJS的ASP.NET MVCvalidation表单

我在MVC 4和AngularJS(+ twitter引导)项目。 我通常在我的MVC项目中使用“jQuery.Validate”,“DataAnnotations”和“Razor”。 然后我在我的web.config中启用这些键来validation客户机上模型的属性: <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 例如,如果我在我的模型中有这个: [Required] [Display(Name = "Your name")] public string Name { get; set; } 有了这个Cshtml: @Html.LabelFor(model => model.Name) @Html.TextBoxFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) html结果会: <label for="Name">Your name</label> <input data-val="true" data-val-required="The field Your name is required." id="Name" name="Name" type="text" value="" /> <span class="field-validation-valid" […]

无法读取未定义的属性“协议”

在尝试从API获取数据时在控制台中获取该错误。 有人有这个问题吗? var url = "https://api.website.com/get/?type=events&lat=" + localStorage.getItem('latitude') + "&lng=" + localStorage.getItem('longitude') + "&distance=50"; $http({ headers: { 'Content-type': 'application/json' } }) $http.get(url).success(function (events) { $scope.events = events; }); 错误: TypeError: Cannot read property 'protocol' of undefined at Gb (http://localhost:38772/www/js/plugins/angular.min.js:114:238) at s (http://localhost:38772/www/js/plugins/angular.min.js:65:249) at new EventsController (http://localhost:38772/www/js/angular.js:4:5) at d (http://localhost:38772/www/js/plugins/angular.min.js:30:452) at Object.instantiate (http://localhost:38772/www/js/plugins/angular.min.js:31:80) at http://localhost:38772/www/js/plugins/angular.min.js:61:486 at […]

SyntaxError:预期expression式,得到'<'

我得到了SyntaxError: expected expression, got '<'当我执行下面的节点代码时,在控制台中SyntaxError: expected expression, got '<'错误 var express = require('express'); var app = express(); app.all('*', function (req, res) { res.sendFile(__dirname+'/index.html') /* <= Where my ng-view is located */ }) var server = app.listen(3000, function () { var host = server.address().address var port = server.address().port }) 错误: 我正在使用Angular Js,它的文件夹结构像波纹pipe 我在这里错过了什么?

ngIf和ngSwitch AngularJS

ngIf和ngSwitch什么实际区别? 这两个指令都操纵DOM,但ngSwitch更加冗长。 ngIf是典型的情况下,除非你需要什么大的东西,在这种情况下使用ngSwitch ? ngSwitch和ngIf是不是直接replace的情况? 或者是他们唯一的实际区别的语法?

AngularJS中的$ scope是什么?

我是AngularJS的新手,我不明白AngularJS中的$scope是什么。 有人可以请尽可能简单地解释$scope在AngularJS中做什么,我们可以用它来做什么。 请用一种完全不懂编程的人来解释。 也可以有人以最简单的方式逐行解释代码吗? function MyController($scope) { $scope.username = 'World'; $scope.sayHello = function() { $scope.greeting = 'Hello ' + $scope.username + '!'; }; };