如果您想了解AngularJS实现图片旋转的相关知识,那么本文是一篇不可错过的文章,我们将对CSS进行全面详尽的解释,并且为您提供关于angularjs–AngularJS:动态载入CSS和JS文件、
如果您想了解AngularJS 实现图片旋转的相关知识,那么本文是一篇不可错过的文章,我们将对CSS进行全面详尽的解释,并且为您提供关于angularjs – Angular JS:动态载入CSS和JS文件、angularjs – Angular.js如何更改元素css类点击和删除所有其他、angularjs – 从Angular 2组件中的CDN加载css、angularjs – 混合Angular 1.x Angular 6应用程序,包含Angular 1.x中的vanilla JS和TS文件的有价值的信息。
本文目录一览:- AngularJS 实现图片旋转(CSS)(angularjs页面跳转)
- angularjs – Angular JS:动态载入CSS和JS文件
- angularjs – Angular.js如何更改元素css类点击和删除所有其他
- angularjs – 从Angular 2组件中的CDN加载css
- angularjs – 混合Angular 1.x Angular 6应用程序,包含Angular 1.x中的vanilla JS和TS文件
AngularJS 实现图片旋转(CSS)(angularjs页面跳转)
图片旋转基于 CSS:transform:rotate(**deg)
实现,Angular 用于动态绑定 deg 数:
controller:(其实可以省略)
lang:js
$scope.img = {src:"xxx.png", rotate=0};
HTML:
lang:html
<button ng-click="img.rotate=img.rotate+90">向右转</button>
<button ng-click="img.rotate=img.rotate-90">向左转</button>
<img ng-src="img.src">
angularjs – Angular JS:动态载入CSS和JS文件
1.我有和index.html,所有文件将在点击或加载时动态加载.
//index.html <signin button> <signup button> // etc.,//on-clicking signin button a SignIn-page will load in the below div <div id="bodyview"></div> // end of index.html
现在我的登录页面看起来有点像下面的结构
/*a div where my accordion menu will load when the *below submit button is clicked*/ <div id="menu"></div> //other sign-in-form stuff will follow on... //submit button at the end <submit button> //only on clicking the submit button the menu will be loaded
现在我的问题是,虽然我可以加载手风琴menu.html文件,我无法加载它依赖的css和js文件.我已经研究了大多数stackoverflow讨论和很多其他..但没有一个为我工作.
任何人都可以帮助确定使用Angular JS加载css和js依赖关系的方法?
任何帮助不胜感激提前致谢
这是一个用于动态加载CSS文件的示例服务.您可以轻松地修改它来加载JS文件.
https://github.com/Yappli/angular-css-injector
angularjs – Angular.js如何更改元素css类点击和删除所有其他
<span id="1" ng-ng-click="tog=my-class"></span> <span id="2" ng-ng-click="tog=my-class"></span>
干杯!
function MyController ($scope) { $scope.collection = ["Item 1","Item 2"]; $scope.selectedindex = 0; // Whatever the default selected index is,use -1 for no selection $scope.itemClicked = function ($index) { $scope.selectedindex = $index; }; }
然后我的模板看起来像这样:
<div> <span ng-repeat="item in collection" ng-https://www.jb51.cc/tag/dind/" target="_blank">dindex }" ng-click="itemClicked($index)"> {{ item }} </span> </div>
仅供参考$ index是ng-repeat指令中的一个魔术变量。
您可以在指令和模板中使用同样的示例。
这里是一个工作plnkr:
http://plnkr.co/edit/jOO8YdPiSJEaOcayEP1X?p=preview
angularjs – 从Angular 2组件中的CDN加载css
import { Component,OnInit } from '@angular/core'; @Component({ selector: 'app-auth',templateUrl: './auth.component.html',styleUrls: [ 'https://fonts.googleapis.com/css?family=Dosis:400,500,600,700','http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css','./assets/css/bootstrap.min.css','./assets/css/main.css','./assets/css/responsive.css','./auth.component.css',],}) export class AuthComponent implements OnInit { constructor() { } ngOnInit() { } }
前两个网址不起作用.我收到一个错误:
ncaught错误:找不到模块“./https://fonts.googleapis.com/css?family=Dosis:400,700”
我可以通过将其直接包含在HTML中来使其工作,但我认为这不是正确的方法.
编辑:我甚至尝试使用封装:ViewEncapsulation.None,这没有帮助.
解决方法
@import "https://fonts.googleapis.com/css?family=Dosis:400,700"; @import "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css";
angularjs – 混合Angular 1.x Angular 6应用程序,包含Angular 1.x中的vanilla JS和TS文件
我似乎无法添加到JS控制器的路由.
我依赖于以下example并执行以下操作:
const statesConfigBlock = ['$stateProvider',$stateProvider => { $stateProvider.state('main',{ url: '/main',templateUrl: 'app/components/layout/mainView.html',controller: 'mainController as main' }) }]; appModuleAngularJS.config(statesConfigBlock);
虽然我有一个mainCtrl.js文件定义为:
var app = angular.module('myApp',[]); (function(app) { 'use strict'; app.controller('mainController',[ function () { console.log("blah"); }]); })(app);
当我运行应用程序时,我得到:
The controller with the name ‘mainController’ is not registered
但是当我在控制台中运行时,我确实看到了它:
angular.module('myApp')._invokeQueue.filter(function(el){ return el[0] === "$controllerProvider"; }).map(function(el){ return el[2]["0"]; });
解决方法
首先,我创建了一个包含模块声明的js文件:
appDependencies = []; app = angular.module('myApp',appDependencies);
所有Angular 1.x控制器和服务都使用全局变量app,如下所示:
(function(app) { 'use strict'; app.controller('mainController',[ function () { console.log("blah"); }]); })(app);
最后,Angular 1.x模块ts文件使用全局应用程序并向其添加依赖项:
... declare const app: any; declare var appDependencies: any; export const appModuleAngularJS = app; angular.forEach([ uiRouter,upgradeModule.name ],module => { appDependencies.push(module); }); ... const statesConfigBlock = ['$stateProvider',controller: 'mainController as main' }) }]; appModuleAngularJS.config(statesConfigBlock); ...
现在,index.html文件中js导入的顺序非常重要.应该首先应用减速文件,然后是所有Angular 1.x控制器和服务,然后是转换为js文件的* .ts文件.
这个解决方案对我有用,但我非常乐意阅读更好的解决方案.
干杯!
今天的关于AngularJS 实现图片旋转和CSS的分享已经结束,谢谢您的关注,如果想了解更多关于angularjs – Angular JS:动态载入CSS和JS文件、angularjs – Angular.js如何更改元素css类点击和删除所有其他、angularjs – 从Angular 2组件中的CDN加载css、angularjs – 混合Angular 1.x Angular 6应用程序,包含Angular 1.x中的vanilla JS和TS文件的相关知识,请在本站进行查询。
本文标签: