I am working on improving the UI of a website, and needed to use Semantic JS with it. The website was written in Angular, and the one piece of Semantic functionality that was not working was Dropdowns. The styling worked fine, but as soon as I tried to initialize the dropdown with a
$('...').dropdown({options});
I encountered a "$('...').dropdown is not a function" error. Looked around and nowhere mentioned the answer to my problem.
Since SemanticJS modifies the $ operator from Jquery, Jquery needs to be included before SemanticJS.
//Index.html//
<html>
<head>
</head>
<div ng-view></div>
<script src="jquery.blah.min.js"></script>
<script src="semantic.min.js"></script>
</html>
Related
I am new to the bootstrap framework, but already I want to be able to use AngularJS rather than the provided jQuery that comes out of the bootstrap box. The documentation for BootstrapUI seems easy enough, I can simply download the code from github and include it in my Django project.
What I am not so unclear on, and maybe I missed this in the documentation somewhere, but is this intended to fully replace the javascript components of bootstrap? For example there are a lot of JS libraries that are being delivered via CDNs in the bootstrap examples that appear to make the site browser independent. For example, in the jumbotron examples, I see the following code:
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="' + {% static 'bootstrap/docs/assets/js/vendor/jquery.min.js'%} + '"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"
integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous">
</script>
<script src="{% static 'bootstrap/dist/js/bootstrap.min.js' %}"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="{% static 'bootstrap/docs/assets/js/ie10-viewport-bug-workaround.js' %}"></script>
With BootstrapUI is this something I take out or leave in? Just what exact steps do I need to perform in order to use Angular instead of jQuery in a bootstrap powered site? The documentation doesn't really go over this. Please point me to the right place if I've missed something.
UI-Bootstrap basically contains a bunch of Bootstrap components where the original JavaScript/jQuery has been re-written and wrapped in AngularJS directives which can be easily dropped into your application.
As per the docs,
This repository contains a set of native AngularJS directives based on Bootstrap's markup and CSS. As a result no dependency on jQuery or Bootstrap's JavaScript is required.
I'm new to angular 2.0. Actually I'm blocked by referencing the angular related resources.
As a beginner, I would like to know which js file to reference (compiled TypeScript) in Index.html to start manipulating with Angular Js 2.0.
In the tutorial of http://angular.io I noticed several references below but I'm not sure which one shall I use in my own project. Seems none of the reference below related with Angular by looking at the names. I'm really confused now.
<script src="https://npmcdn.com/zone.js#0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata#0.1.3"></script>
<script src="https://npmcdn.com/systemjs#0.19.27/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
For my team, we're between projects, but I'm performing some basic research on TypeScript and how to use Angular 1.x with it, considering that Angular 2 is still being baked. I usually use Plunkr to make small-scale prototypes so that we can see how something works and mess with it in-situ during tech demos and stuff.
The problem, though, is I tried to make a very basic Angular 1.x + TS setup in this plunker, but have been running into issues getting it to work properly. I think some of the problem is the client-side transpilation, but I'm sure that's not the only thing I'm messing up. Specifically...
View Code:
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
</head>
<body>
<div ng-controller="testController as ctrl">
<h1>{{ ctrl.testMethod() }}</h1>
</div>
<!-- Scripts... -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script>
<script type="text/typescript" src="app.ts"></script>
<script type="text/typescript" src="controllers.ts"></script>
<script type="text/typescript" src="registrations.ts"></script>
<!-- Required for web transpilation... -->
<script type="text/javascript" src="//niutech.github.io/typescript-compile/js/typescript.min.js"></script>
<script type="text/javascript" src="//niutech.github.io/typescript-compile/js/typescript.compile.js"></script>
</body>
</html>
I got the client-side transpilation from this StackOverflow question, but that question's resolution was either, 'Just do it in Visual Studio!' or 'transpile your TypeScript, then plug the JavaScript into Plunkr,' which doesn't work for me, because my team is considering transitioning to TypeScript in the first place - we need to be able to work with typescript, thus the prototype to help us understand how it works. Additionally, that question notes that the transpilation parts are actually significantly outdated.
Question: First, is there an updated clientside TypeScript-to-JavaScript transpiler that I can link to in my prototype plunker? Second, are there any better resources to refer to on how to get Angular 1 to work with TypeScript? I've had very, very little luck finding anything that talks about how to make TypeScript work with Angular 1.x...
Edit:
Turns out you can use typescript on plnkr, which I just learned from the comments below http://embed.plnkr.co/suu7Yg/preview
For implicit mode all this requires is creating a file with the appropriate extension, i.e. script.ts or style.scss, and then referencing it in the head with the expected compiled extension, i.e. script.js or style.css. Very cool, plnkr!
I'm fairly certain Plunker doesn't support typescript (though of course I could be wrong) (edit: yup I was wrong, it's just not obvious that this is a feature). However, I can offer an idea for a possible solution of what you're trying to accomplish.
Try moving your small-scale prototypes and demos over to codepen instead. They're both pretty comparable apps I use all the time, and codepen currently supports typescript so if that's something you need to play with you got it.
It's hidden behind the little gear, along with external js file includes:
Turn on typescript:
Boom. Good to go for your live demos. Hope that helps!
As mentioned by #wesww in his amended answer, Plunker supports server-side compilation of TypeScript. What I mean by that is that when your TypeScript code is sent to the preview server, it is sent un-transformed.
Suppose you have a file script.ts, written in TypeScript, but the index.html of your project requests script.js, Plunker's preview server will compile your file on the fly and serve the compiled version.
You can configure how you want the TypeScript compiler to work by creating a tsconfig.json file (consistent with normal CLI usage) to define your settings.
Please see Definitive Guide to Comiplation on Plunker for more information.
I'm not familiar with plunk is but it's possible to transpile typescript in the browser by just including node_modules/typescript/typescript.js file and use the Compiler API. Checkout my Compiler API playground in the browser: https://cancerberosgx.github.io/typescript-in-the-browser/typescript-compiler/#example=tsTranspilingProject1
See Dynamic execution of TypeScript in the browser for details
So I am wanting to learn more about how to use AngularJS $route as it seems to be the way to go for my single page application. Naturally, the best place to start is the documentation. They have a nice little Plunker for me to visually and hands-on see how it works. Next up, playing with it and making it my own. Before I can start messing with it to make it my own though, I need it working outside the Plunker: so I made copies of each file and put them all in the same directory.
However, I am getting the following errors:
TypeError: angular is undefined script.js:3:0
ReferenceError: angular is not defined index.html:14:4
The line for the first error is:
angular.element(document.getElementsByTagName('head')).append(angular.element('<base href="' + window.location.pathname + '" />'));
and the line for the second error is:
angular.module('ngRouteExample', ['ngRoute'])
So to me it is obvious that it is not registering that AngularJS is referenced or something. Nothing about the code is breaking, it just doesn't recognize AngularJS. Why is this? How do I fix this?
Plunker
Original documentation
Have a look at the Angular documentation here. Make sure you have included the Angular library in your index.html (or index.jsp/index.aspx).
<!doctype html>
<html ng-app>
<head>
<title>My Angular App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
</body>
</html>
Not sure why but the Plunker uses
//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js
instead of
https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js
Easily grazed over it. My bad. Thought Plunker, JSFIDDLE and all that use direct URLS.
Found error by starting to paste everything back in Plunker.
Recently, I have an error regarding to my pagination that can't be updated after filter. Luckily, this was managed, however, now I'm dealing with a conflict regarding to the usage of ui-bootstrap. As I have my project, Im using,
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
Based on the codes that I'm relaying with they used,
<script src="angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.2.0.js"; type="text/javascript"></script>
***Here's the thing, I do have as well a datepicker in my codes. But when I used the
<script src="angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.2.0.js"; type="text/javascript"></script>
this datepicker doesn't work. If now I will switch to my formerly ui-bootstrap
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
, now the pagination after filter can't be used but the datepicker will work. Any ideas how to solve this or what I'm going to do? thanks!
From what I understand, your problem is due to directive conflict; e.g. you have a custom directive defined called "datepicker":
angular.module('App').directive('datepicker', ...
That's going to cause problems because UI-Bootstrap also defines a directive with the same name. The simplest solution would be to simply exclude the datepicker module from UI-Bootstrap.
https://angular-ui.github.io/bootstrap/
On their website, you can choose "create a build". It will allow you to download a version of UI-Bootstrap custom-tailored to your needs by adding and removing certain modules, like the datepicker.
Then you will drop the file into your HTML:
<script src="path/to/your/ui-bootstrap.min.js"></script>
I notice you are using Bower to manage your dependencies. Unfortunately, Bower can't work with a custom UI-Bootstrap build; you'll have to manage the file yourself (put it in a subdirectory, like "assets/").