Ionic and AngularJS - javascript

Please forgive me for my little knowledge about this, but I have just started using Ionic to develop a hybrid app. Ideally i wanted to use my own javascript and so far it doesn't seem to work. Is this a conflict with Angular? I want my own external JS file so I can handle what happens with inputs and don't want to use Angular. Any info would be appreciated.
As to what doesn't work, i'm trying to use innerHTML to replace a value on page load and it seems to load in before the DOM so I get an error in the console. Tried moving the placement of the external js file reference but still doesn't work.

You probably should not be using innerHTML. Angular has this built in using data-binding:
<div>{{aVariableTiedTo$Scope}}</div>
Where aVariableTiedTo$Scope is a property defined in your controller on your $scope object.

Related

How to upgrade angularjs with jquery to angular 9?

I have a project in angularjs and I want to upgrade this project to Angular9.
The problem is most of the project uses jQuery features such as query-ui, selectors, change the dom, animations, bootstrap and more.
Say it may only my problem since I do not want to use jQuery after the upgrade, just to do stuff in the angular way. so I guess to convert jQuery to angular.
I wonder if there is a way to do that? or I need to go manually and remove the jQuery code to new one?
I know I can import jQuery to my project, but sometimes I use $('#some').innerHtml('bla') and this is not what I want to do in my new code.
What are the ideas or approaches should I consider and use?

how to resolve defineAlreadyDefined issue in dgrid?

we are working on a one page website project which wad already build in jquery and javascript at client side and cake php at service side but one for grid we want to use DGRID of dojo framework and for that when we try to integrate dgrid with our project we are getting this error
defineAlreadyDefined
In case we try to open another module because the content coming from AJAX and updated in same page.
We had included dojo.js in main page which loads only once and module included with require in each individual file.
Any help will be appreciated.
Well, this happens when we use two or more different libraries which expose same define method to create new widgets.
solution:
in our project we modified the name of exposed value like instead of define we replaced the customDefine in other widget so if we need define of first library we use define (as it was earlier) and if we need define of second library basically we used customDefine.
Note:- Before making above changed just verify that you are not adding same or similar libraries more than once in your project. In our project we were using dojo and d3 libraries.
This is how we resolved in our project.
Problem with almost similar solution - Trouble adding search widget to ArcGIS Shortlist Story App
hoping this will help you:)

Windows Metro app and Angular route ui and dynamic content

I have an existing angular / phonegap app that I'm trying to port to a windows metro app for win8. I've replaced my jQuery with a metro specific version and I've wrapped each angular module in the MSAp.execUnsafeLocalFunction method and I'm getting the application to sort of compile.
What is happening is that the page is built using angular ui router, so I'm able to see the dynamically created page, with angular ui router combining the 3 or 4 partials based on the route. However, when Angular starts to go through ng-bind, ng-repeat, etc... I'm getting the following error, "JavaScript runtime error: Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, the might be unsafe..."
I've looked to see how others have overcome this issue, but I have not found anything that works. I'm worried that what I'm doing is going to have force me to rewrite the application using the WinJS library.
Does anyone have any resources or experience that can help me with this?
What works for me is adding the ng-csp directive to the HTML tag. This disables some of the dynamic content stuff of Angular. I didn't even wrap anything in exeUnsafeLocaFunction. I'm not sure if it will work on Angular UI Router though...
More on the ng-csp directive here...

Django - Load template with jQuery into variable

I'm working with a client that has a view that, after a user logs in, this view loads a template, that dynamically draws a canvas with jQuery, and generates an image copy of the canvas.
They want to protect the jQuery code, hiding the process in the python code.
I tried using PyExecJS, but it doesn't support jQuery, since there is no DOM.
I've also tried urllib2, mechanize and Selenium, but none worked.
Is there an alternative or have I missed something?
Update/Resolution: In case someone stumbles onto this question: I ended up using Selenium for Python to load the JS function, fed it the necessary data and extracted the image from it. It has a bit of an overhead, but since the main goal was to keep the JS code obfuscated, it worked.
If I understand correctly, you are trying to hide jquery code.
You can't hide jquery code from the user, because django processes python code before it serves up the template, there's no way to protect jquery code with python. Really the best thing you can do is to minimize and obfuscate the code, but that only makes it difficult for human reading.

ruby on rails v2 prototype issues

am going with some background information first
I have a clash between Dojo and Prototype.js on the client side, so to fix this I rewrote the client side hooks in plain javascript.
But now the issue is since Prototype.js is not being imported, the ajax functions created by the render do not work. Is there anyway I could rewrite them? Or use jquery atleast. I am using RoR v2.3.8 and updating is out of the question, so is messing with the dojo or dojo content.
I thought I could try send the prototype.js tag with the response but I have no idea how, after reading a lot of documentation am told to insert some javascript tag but where.
also is there anyway to edit actioncontroller

Categories

Resources