在本文中,我们将带你了解html–如何从angular(类型脚本)中的浏览器获取客户端IP地址在这篇文章中,我们将为您详细介绍html–如何从angular(类型脚本)中的浏览器获取客户端IP地址的方
在本文中,我们将带你了解html – 如何从angular(类型脚本)中的浏览器获取客户端IP地址在这篇文章中,我们将为您详细介绍html – 如何从angular(类型脚本)中的浏览器获取客户端IP地址的方方面面,并解答angular获取url常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的angularjs – 如何从angular $location获取主机基础、angularjs – 如何从angular-ui/ui-tinymce配置tinymceOptions、angularjs – 如何从angular.js中的重定向URL捕获并获取值?、angularjs – 如何从angular.js数组中删除元素/节点。
本文目录一览:- html – 如何从angular(类型脚本)中的浏览器获取客户端IP地址(angular获取url)
- angularjs – 如何从angular $location获取主机基础
- angularjs – 如何从angular-ui/ui-tinymce配置tinymceOptions
- angularjs – 如何从angular.js中的重定向URL捕获并获取值?
- angularjs – 如何从angular.js数组中删除元素/节点
html – 如何从angular(类型脚本)中的浏览器获取客户端IP地址(angular获取url)
我想在类型脚本中执行此操作而不是在java脚本中这是可能的,如果不是如何使用类型脚本执行此操作
–
所以我可以举例
1)在将表单提交到后端的数据库时设置这些变量
2)我可以例如为用户显示他正在使用的浏览器
任何帮助将不胜感激
解决方法
我把它作为我的问题的基础,但我没有解决它,因为它给了我互联网服务器的公共IP.
对于具有DHCP的内部网络,请通过以下方式更改URL:
getIpCliente(): Observable<string> { return this.http.get('http://api.ipify.org/?format=jsonp&callback=JSONP_CALLBACK') // ...using post request ' .map((res:Response) => {console.log('res ',res); console.log('res.json() ',res.text()); //console.log('parseado ',JSON.parse(res.text())); console.log('parseado stringify ',JSON.stringify(res.text())); let ipVar = res.text(); let num = ipVar.indexOf(":"); let num2 = ipVar.indexOf("\"});"); ipVar = ipVar.slice(num+2,num2); console.log('ipVar -- ',ipVar); return ipVar}); // ...and calling .json() on the response to return data //.catch((error:any) => Observable.throw(error.json().error || 'Server error')); //...errors if any }
我希望能为你的朋友服务
拥抱!
angularjs – 如何从angular $location获取主机基础
var redirectUri = $location.absUrl(); redirectUri = redirectUri.substr(0,redirectUri.indexOf('#'));
window.location.origin + window.location.pathname
这将返回http:// example-domain / someApp
即使使用虚拟目录/路径,这也将提供整个基本URL.
但是,IE不支持原点.因此,您可以连接url的组件以提供基本目录,如下所示:
window.location.protocol + "//" + window.location.hostname + window.location.pathname
这将返回http:// example-domain / someApp
如果使用虚拟目录,你将难以使用$location,因为$location.path()返回哈希后,$location.host()只会返回域,而不是域和目录,这就是window.location .hostname window.location.pathname给你.
angularjs – 如何从angular-ui/ui-tinymce配置tinymceOptions
这是git链接 – https://github.com/angular-ui/ui-tinymce
如果您点击一个特定的选项,您将看到如何配置非角度锡罐,如下所示:
tinymce.init({ resize: false });
所以要用ui-tinymce做等同的定制,而不是tinymce.init(),你可以在范围变量$ scope.tinymceOptions内设置选项。因此,配置ui-tinymce不允许用户调整大小的示例,宽/高为400/300,允许打印,文本颜色/背景选择器将是:
myAppModule.controller('MyController',function($scope) { $scope.tinymceOptions = { resize: false,width: 400,// I *think* its a number and not '400' string height: 300,plugins: 'print textcolor',toolbar: "undo redo styleselect bold italic print forecolor backcolor" }; });
你的看法可能看起来像这样(注意tinymceOptions):
<textarea ui-tinymce="tinymceOptions" ng-model="tinymceModel"></textarea>
ui-tinymce应该有一些内置的插件,您可以在这里找到文档:http://www.tinymce.com/wiki.php/Plugins
有关工具栏选项的完整列表,请参阅:http://www.tinymce.com/wiki.php/Controls
从我记得,你不能在事实改变tinymceOptions之后。我的意思是,在编辑器加载之后,如果要稍后更改一些$ scope.tinymceOptions,那么这些更改不会在编辑器中自动更新,因为我相信ui-tinymce代码将选项传递给tinymce.init ()加载时只有一次。
您还可以通过使用plain tinyMce JavaScript钩子手动设置编辑器内容,例如:
tinyMCE.activeEditor.setContent('<h1>hello world</h1><p>this is my story. the end.</p>');
同样,您可以使用getContent()参见:http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.getContent
但是,我相信您也可以通过本示例中的$ scope.tinymceModel变量访问编辑器内容。 (使用的情况是,如果您点击按钮保存编辑器内容,那么如何获取编辑器内容…)
但是更有角度的方式是通过ng模型和范围变量来完成所有操作,而不是依赖于原始的tinymce javascript api。
希望有帮助。总之,ui-tinymce是一个非常薄的包装在简单的TinyMce周围。所以任何你可以用常规的tin子做的事情,你可以在大多数情况下与角度化的版本。我认为这就是为什么没有很多文档来定制ui-tinymce,但这个事实对于新的初学者来说是不明显的。
angularjs – 如何从angular.js中的重定向URL捕获并获取值?
示例网址:
https://locahost:3000/auth/authorize?response_type=code&client_id=abzefcbbkjajsdd&scope=userfetchit&redirect_uri=localhost&nonce=32324
当我调用上面的URL时,它会在新窗口中显示登录页面,在我给出电子邮件和密码后,它会被重定向到另一个URL,如下所述
重定向的网址:
https://localhost:3000/auth/localhost?code=8dacae52ee284db3dc776aa6d3563912
预期结果 :
现在,我想从angular.js中的上述URL获取代码值“8dacae52ee284db3dc776aa6d3563912”.
HTML代码:
<html ng-app='app' ng-controller='LoginController'> <head> </head> <body> <div> <div> <button type="button"ng-click="tokenLogin()"> New Login </button> </div> </div> <pre>{{ cleanData | json}}</pre> </body> </html>
控制器代码:
angular.module('app',[]) .controller('LoginController',['$location','$window','$scope','$filter',function($location,$window,$scope,$filter) { $scope.tokenLogin = function() { var url = 'https://localhost:3000/auth/authorize?response_type=code&client_id=abzefcbbkjajsdd&scope=userfetchit&redirect_uri=localhost&nonce=32324'; $window.open(url); }; }]);
解决方法
.state('yourstate',{ url: '/localhost?:code',templateUrl: 'localhost.html' });
然后在你的控制器中你可以打电话:
console.log($stateParams.code);
就是这样.您可以将此值设置为范围变量或任何内容.
angularjs – 如何从angular.js数组中删除元素/节点
为了演示的目的,这里是一些代码:
for(i=0;i<$scope.items.length;i++){ if($scope.items[i].name == 'ted'){ $scope.items.shift(); } }
我想从视图中删除第1个元素,如果有名称ted右?它工作正常,但视图重新加载所有的元素。因为所有的数组键已经移位。这是在我创造的移动应用程序中造成不必要的滞后。
任何人都有这个问题的解决方案?
splice
:$ scope.items.splice(index,1);.
Here is an example:
HTML
<!DOCTYPE html> <html data-ng-app="demo"> <head> <script data-require="angular.js@1.1.5" data-semver="1.1.5" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body> <div data-ng-controller="DemoController"> <ul> <li data-ng-repeat="item in items"> {{item}} <button data-ng-click="removeItem($index)">Remove</button> </li> </ul> <input data-ng-model="newItem"><button data-ng-click="addItem(newItem)">Add</button> </div> </body> </html>
JavaScript
"use strict"; var demo = angular.module("demo",[]); function DemoController($scope){ $scope.items = [ "potatoes","tomatoes","flour","sugar","salt" ]; $scope.addItem = function(item){ $scope.items.push(item); $scope.newItem = null; } $scope.removeItem = function(index){ $scope.items.splice(index,1); } }
关于html – 如何从angular(类型脚本)中的浏览器获取客户端IP地址和angular获取url的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于angularjs – 如何从angular $location获取主机基础、angularjs – 如何从angular-ui/ui-tinymce配置tinymceOptions、angularjs – 如何从angular.js中的重定向URL捕获并获取值?、angularjs – 如何从angular.js数组中删除元素/节点的相关信息,请在本站寻找。
本文标签: