我正在努力提高1.5角度组件的速度.我一直在关注Todd Motto的视频,以获得组件以及angular的文档 https://docs.angularjs.org/guide/component.
在这一点上,组件似乎取代了使用控制器的指令,但在我们的1.5代码中,我们仍然会使用指令进行dom操作.
$ element,$ attrs在组件控制器内的目的是什么?这些似乎可用于操纵.这是文档中关于plunker的链接.我知道他们没有使用$元素,但这是我正在阅读的例子.http://plnkr.co/edit/Ycjh1mb2IUuUAK4arUxe?p=preview
但在像这样的代码......
angular
.module('app', [])
.component('parentComponent', {
transclude: true,
template: `
<div ng-transclude></div>
`,
controller: function () {
this.foo = function () {
return 'Foo from parent!';
};
this.statement = function() {
return "Little comes from this code";
}
}
})
.component('childComponent', {
require: {
parent: '^parentComponent'
},
controller: function () {
this.$onInit = function () {
this.state = this.parent.foo();
this.notice = this.parent.statement();
};
},
template: `
<div>
Component! {{ $ctrl.state }} …Run Code Online (Sandbox Code Playgroud) 我在读一本关于上海社会科学院教程这里然后我尝试了一些其他办法,我不能得到本教程中的答案.问题就在于此.我在gulpfile.js中有这段代码
gulp.task('compileNavbar', function() {
gulp.src('assets/css/sass/**/*.navbar.scss')
.pipe(sass('navbar.css'))
.pipe(gulp.dest('assets/css/'));;
});
Run Code Online (Sandbox Code Playgroud)
截至目前,我只有资源/ css/sass/guest.navbar.scss,这段代码正确定位scss文件并将输出css文件放在正确的目录中但是 css被命名为guest.navbar.css我没有期望.我希望它被命名为navbar.css,但如何?
我在本机javascript中有这个代码,它可以正常工作.它记录文本框的当前值
<script>
var boom = function(val) {
console.log(val);
};
</script>
<input type="text" onclick="boom(this.value)"/>
Run Code Online (Sandbox Code Playgroud)
然后我想在不使用模型的情况下在AngularJS上做同样的事情.这是代码:
$scope.boom = function(val) {
console.log(val);
};
<input type="text" ng-click="boom(this.value)"/>
Run Code Online (Sandbox Code Playgroud)
但它始终记录未定义!
为什么?
在我们创建chrome应用程序时,我们将脚本放在manifest.json文件中的background属性上(这将作为应用程序的背景/事件页面).我想要的是,我想在后台脚本上使用AngularJS,但我不知道如何.而且,它可能吗?我刚看到一些答案,但它是针对chrome扩展的.我尝试在Chrome应用程序中使用该解决方案,但它没有用.
- 编辑 -
我做的是,我从manifest.json文件中更改了一些
由此 ..
"app": {
"background": {
"scripts": ["assets/js/background.js"]
}
},
Run Code Online (Sandbox Code Playgroud)
到这个..
"app": {
"background": {
"page": "views/background.html"
}
},
Run Code Online (Sandbox Code Playgroud)
和我的background.html
<html ng-app="backgroundModule" ng-csp>
<head>
<meta charset="UTF-8">
<title>Background Page (point background property here to enable using of angular in background.js)</title>
</head>
<body>
<!-- JAVASCRIPT INCLUDES -->
<script src="../assets/js/vendor/angular1.2.min.js"></script>
<script src="../assets/background.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和我的background.js
var backgroundModule = angular.module('backgroundModule', []);
backgroundModule.run(function($rootScope, $http) {
$rootScope.domain = 'http://localhost/L&D/index.php'; …Run Code Online (Sandbox Code Playgroud) window.open('branchMonitoring/', 'Testing Dual Monitor', 'resizable=1, scrollbars=1, fullscreen=0, height=200, width=650, screenX=0 , left=1280, toolbar=0, menubar=0, status=1');
Run Code Online (Sandbox Code Playgroud)
我使用此代码在第二台监视器上打开了一个新窗口,但新窗口仍在第一台监视器上打开,并且不能超出第一台监视器的边界。我试图将“ left”更改为更高的值,但仍然没有运气。
请兄弟帮我。我正在使用最新的谷歌浏览器和Windows 8双显示器。
请注意,使用FireFox浏览器时,此解决方案对我有效。但是我需要让它在chrome上运行。
我有一个问题,因为chrome api函数是异步的,我不能得到它的返回值.请考虑以下代码.我正在使用angularjs
$scope.storageGet = function(param) {
var returnData;
chrome.storage.local.get(param.storageName, function(data) {
returnData = data;
});
return returnData;
};
Run Code Online (Sandbox Code Playgroud)
当我试图这样称呼时:
console.log($scope.storageGet({'storageName': 'users'}));
Run Code Online (Sandbox Code Playgroud)
它在控制台中打印'undefined'.我想看到的是存储在chrome存储中的用户的对象.好吧,我确信我有chrome存储数据.
这是存储在我的 chrome 本地存储中的 JSON
{"users":[
{"password":"123","userName":"alex"},
{"password":"234","userName":"dena"},
{"password":"343","userName":"jovit"}
]}
Run Code Online (Sandbox Code Playgroud)
是否可以删除“用户”中的特定项目?我试过这个代码但没有运气
chrome.storage.local.remove('users[0]', function(){
alert('Item deleted!');
});
Run Code Online (Sandbox Code Playgroud) javascript google-chrome google-chrome-extension google-chrome-app