Getting JSON file from WordPress through Cloud9 returns a Cloud9 html file - angularjs

I have been using Cloud9 to make an Ionic app.
So far, the frontend of the app is doing fine. I use the ionic-framework through Cloud9.
My backend is another Cloud9 project. It uses WordPress to make a specific custom post type with advanced custom fields. It then uses WP REST API to generate that data in a json format. I can access my custom post type and its fields when I run the WordPress on Cloud9 using its /wp-json/posts?type=[specific type].
The problem is, when using a $http.get request in my ionic app, it doesn't work at all. If I use $http.get on a json file I downloaded from my WordPress and added in the workspace of my ionic app, everything works fine.
So, I have a problem getting json data from a WordPress site hosted using Cloud9 through an ionic app, also in a Cloud9 workspace.
Both workspaces are separated and run at the same time.
My code to load the json file is the following :
var defer = $q.defer();
$http.get('LINK TO .../wp-json/posts?type=[post type]', { cache: 'true'})
.success(function(data) {
defer.resolve(data);
});
return defer.promise;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
As mentionned, when I replace the link with [name of json file].json, a file that was directly downloaded from the REST API generated json and so that is identical to the site I'm trying to get, it doesn't work.
When I console.log(data), instead of logging the data for each custom post (what happens with the download .json), it logs this :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2005/10/profile">
<!--C9LOCAL_CODE_INJECT_PLACEHOLDER-(login-head)-DO_NOT_REMOVE-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Sign-in | Cloud9 IDE - Ajax.org</title>
<meta name="description" content="Meet Cloud9, development-as-a-service for Javascripters and other developers"/>
<meta name="keywords" content=""/>
<link rel="icon" type="image/gif" href="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/homepage/favicon.ico" />
<!--C9LOCAL_CODE_INJECT_PLACEHOLDER-(login-loadedDetectionScript)-DO_NOT_REMOVE-->
<link href="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/style/signin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/js/prefixfree.min.js"></script>
</head>
<body class="">
<script type="text/javascript">
// ClickTale Top part
var WRInitTime=(new Date()).getTime();
// ClickTale end of Top part
</script>
<div id="header">
<a class="logo" href="/"></a>
<div class="social">
<div class="socialMediaBlok">
Tweet
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<div class="socialMediaBlok">
<iframe src="//www.facebook.com/plugins/like.php?href=c9.io&layout=button_count&show_faces=false&width=90&action=like&font=lucida+grande&colorscheme=light&height=21"
allowtransparency="true"
scrolling="no"
frameborder="0"
style="border:none; overflow:hidden;height:20px"></iframe>
</div>
</div>
</div>
<div class="headerdivider"></div>
<div id="signin_window">
<div id="signinViewport">
<div class="pageContainer">
<div id="barForgetPass" class="page">
<form id="resetPasswordForm">
<div class="header">Reset password</div>
<div class="form-holder">
<div id="lbl_inpResetPassword" class="c9-label">
<label for="inpResetPassword">Username or email address</label>
</div>
<div class="c9-textbox">
<div class="c9-txt_fix">
<input type="text" id="inpResetPassword" name="inpResetPassword" disabled2="disabled" />
</div>
</div>
</div>
</form>
<div class="fbox">
<div id="btnRPCancel" class="cancel-button button">Go back</div>
<div id="btnRP" class="action-button button">Reset my password</div>
</div>
<div class="label3">Your password will be reset and you will receive an email with a new password.</div>
</div>
<div id="barSignIn" class="page">
<form id="signinForm">
<div class="header">Please sign in</div>
<div class="form-holder">
<div id="lbl_inpUsernameEmail" class="c9-label">
<label for="inpUsernameEmail">Username or email address</label>
</div>
<div id="txt_inpUsernameEmail" class="c9-textbox">
<div class="c9-txt_fix">
<input type="text" id="inpUsernameEmail" name="inpUsernameEmail" tabindex="1" />
</div>
</div>
<div id="lbl_inpPassword" class="c9-label">
<label for="inpPassword">Password</label>
<a id="forgetlink" class="forgetlink">Forgot?</a>
</div>
<div id="txt_inpPassword" class="c9-textbox">
<div class="c9-txt_fix">
<input type="password" id="inpPassword" name="inpPassword" tabindex="2" />
</div>
</div>
<div class="fbox">
<div id="cbRememberLogin" class="c9-checkbox" tabindex="3">
<div class="check"></div><span>Remember my login</span>
</div>
<div id="btnSignIn" class="action-button button" tabindex="4" accesskey="ENTER">Sign in</div>
</div>
</div>
<div id="barSignInStatusMsg" class="signinstatus-bar">
<div id="lblSignInHeader" class="errorboxContent"></div>
<div id="lblSignInStatus" class="errorboxContent"></div>
</div>
</form>
<!-- <div id="btnLoginViaGitHub" class="c9-button btn-github" style="margin: 13px 0 0 12px;" tabindex="5"></div>-->
<div class="signin_options">
<div class='info'>Or sign in with:</div>
<!--
-->
</div>
</div>
<div id="barActivationLink" class="page">
<form id="activationlinkForm">
<div class="header">Activation email</div>
<div class="form-holder">
<div id="lbl_inpResetPassword" class="c9-label">
<label for="inpResetPassword">Username or email address</label>
</div>
<div class="c9-textbox">
<div class="c9-txt_fix">
<input type="text" id="inpResendConfirmation" name="inpResendConfirmation" />
</div>
</div>
</div>
</form>
<div class="fbox">
<div id="btnALCancel" class="cancel-button button">Go back</div>
<div id="btnAL" class="action-button button">Resend activation email</div>
</div>
<!--div style="clear: both"></div-->
<!--div class="divider" style="margin:40px 5px 0 5px;"></div>
<div class="label3" style="margin:21px 17px 0 17px;">To receive the registration email again please click the button above.</div-->
</div>
</div>
</div>
</div>
<div id="signup_window">
<div class="no_account_yet"></div>
<div class="signuplink-bar">
<div class="bird"></div>
<div class="content">
<a id="btnSignUpUrl" href="/signup">SIGN UP</a> FOR YOUR ACCOUNT
</div>
</div>
</div>
<!-- <div id="terms_of_use">
Terms of use - © 2011 - Register here
</div>-->
<div class="sign_up_now">
<a id="resendactivation">Resend my activation email</a>
</div>
<ul class="bottom_menu">
<li>Home</li>
<li>|</li>
<li>Talk to us at Twitter and Facebook</li>
<!-- <li>|</li>-->
<!-- <li>Terms of use</li>-->
<li>|</li>
<li>Cloud9 IDE, Inc © 2011</li>
</ul>
<script type="text/javascript" src="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/js/components.js"></script>
<script type="text/javascript" src="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/js/code.js"></script>
<script type="text/javascript" src="https://cdn.c9.io/nc-3.1.2733-9ac8c40a/static/oldclient/homepage/js/signin.js"></script>
<!-- ClickTale Bottom part -->
<div id="ClickTaleDiv" style="display: none;"></div>
<script type='text/javascript'>
document.write(unescape("%3Cscript%20src=\"" + (document.location.protocol == "https:"
? "https://clicktale.pantherssl.com/"
: "http://s.clicktale.net/") + "WRc5.js\"%20type=\"text/javascript\"%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var ClickTaleSSL = 1;
if (typeof ClickTale == "function")
ClickTale(48230, 1, "www");
</script>
<!-- ClickTale end of Bottom part -->
</body>
</html>
Also, since I use chrome as a debugger for my app, I use an extension for Access-Control-Expose-Headers. Without this extension, I get another error for the header.

In order to allow services to make API calls to your app (or Wordpress) you'll need to open the Share menu in the top right and make your app public.
In this case, you can lock down your app with authentication in the API so the publicness of your app shouldn't be an issue.

Related

ngRoute can't get data from one view to another

Angular.JS issue with ng-repeat value from inputs
I'm having an issue with ng-repeat, where I can't see to get the values from the input to show on the UI when submitted.
I'm very new to angular JS, hence why I'm trying to build a simple to do app to learn the basics.
On the newItem.html page, there is a form with a function Add(). There are two inputs for the project and the title. There is a button to add the new to do item.
Once the button is clicked and it runs the Add() function, it should add a new object to the toDoList array with the Project and the Task.
On the homePage.html I want to display a project title and the task details. Later down the line I want to generate the entire row on each click but for now I'm just trying to get the text to change.
I'm obviously missing something obvious here, I've read through the documentation for ng-repeat and ng-model, but just can't seem to grasp it.
index.html
<!DOCTYPE html>
<html lang="en" ng-app="ToDoListApp">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>To Do App</title>
<script src="angular/angular.min.js"></script>
<script src="angular-route/angular-route.min.js"></script>
<script src="app.module.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="app/assets/css/home.css">
<link href="https://fonts.googleapis.com/css?family=Acme&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/4c765e5630.js" crossorigin="anonymous"></script>
</head>
<body ng-view ng-controller="toDoCtrl">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous">
</script>
</body>
</html>
homePage.html
<div class="row header">
<div class="col-12">
<h1>DOINGO</h1>
<p>0 Open Tasks</p>
</div>
</div>
<div class="row toDoList">
<div class="row newItem">
<div class="col-2">
<button class="itemComplete btn"><i class="far fa-check-circle fa-2x"></i></button>
</div>
<div class="col-8">
<h4 ng-repeat="Project in ToDoList">{{ToDoList.Project}}</h4>
<p ng-repeat="Task in ToDoList">{{ToDoList.Task}}.</p>
</div>
<div class="col-2">
<button class="btn deleteItem"><i class="far fa-times-circle fa-2x"></i></button>
</div>
</div>
</div>
<div class="row addItemRow">
<div class="col-12 text-center">
<a href="#/newItem"><button type="button" class="btn btn addItem">
<i class="fas fa-plus-circle fa-3x"></i>
</button></a>
</div>
</div>
newItem.html
<div class="row header">
<div class="col-12">
<h1>DOINGO</h1>
</div>
</div>
<div class="row addNewItem">
<form ng-submit='Add()' class="form">
<div class="row projectInput text-center">
<div class="col-12">
<input type="text" ng-model="ToDoList.Project" placeholder="Enter a project title" ng-required>
</div>
</div>
<div class="row taskInput text-center">
<div class="col-12">
<input type="text" ng-model="ToDoList.Task" placeholder="Enter your task details" ng-required>
</div>
</div>
<div class="buttonRow row">
<div class="col-12 text-center">
<button type="submit" class="btn-lg btn-success addItemButton">Add</button>
</form>
<button class="btn-lg btn-danger cancelButton">Cancel</button>
</div>
</div>
</div>
app.module.js
var app = angular.module('ToDoListApp', ['ngRoute']);
app.config(function ($routeProvider, $locationProvider) {
$locationProvider.hashPrefix('');
$routeProvider
.when("/", {
templateUrl: "app/home/homePage.html",
controller: "toDoCtrl"
})
.when("/newItem", {
templateUrl: "app/newItem/newitem.html",
controller: "toDoCtrl"
})
.otherwise({
redirectTo: '/'
})
});
//main controller for app functionality
app.controller('toDoCtrl', function ($scope) {
$scope.ToDoList = []
//add the new to do item to the array
$scope.Add = function () {
$scope.ToDoList.push({
Project: $scope.Project,
Task: $scope.Task
});
$scope.Project = '';
$scope.Task = '';
};
});

Upload an Image to a Web Api using AngularJS

Hi I'm new with Web API's and I'm working with AngularJS and Web API I'm trying to upload an image into a Web API but when I click the button to send the image it gives me an error
I already did the method GET and it shows me all the images that are in that web API but it doesn't work the method POST
here is my code
index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="css/bootstrap.css" media="screen">
<link rel="stylesheet" href="css/bootswatch.min.css">
</head>
<body>
<div ng-app="MarcasApp" >
<div ng-controller="MarcaController">
<div class="container">
<h2>Muestra</h2>
</div>
<input type="button" class="btn btn-info" value="Todos" ng-click="getTodos()">
<form name="formulario" method="post" action="" enctype="multipart/form-data">
<div class="container">
<label for="caption">Id:</label>
<input type="input" class="form-control" ng-model="txtId"/>
</div>
<div class="container">
<label for="caption">Cargar Marcar:</label>
<input type="file" ng-files="getTheFiles"/>
</div><br>
<div class="container">
<input type="submit" value="Enviar Marca" class="btn btn-success"
ng-click="btnGuardar()"/>
</div><br>
<div class="container">
Mensaje:{{msgGuardar}}
</div>
</form>
<div class="panel panel-info">
<ul class="list-group" ng-repeat="marca in marcas">
<li class="list-group-item">
<img src="{{marca.imagen}}">
{{marca.marca1}} + {{marca.marcaId}}
</li>
</ul>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="MarcaJson.js"></script>
</body>
</html>
MarcaJson.js
var app = angular
.module("MarcasApp", [])
.controller("MarcaController", function($scope, $http){
$scope.getTodos =function(){
var apiUrl = 'http://tiendawebapi.azurewebsites.net/api/marcas/';
$http.get(apiUrl).then(function(response){
$scope.marcas = response.data;
});
};
$scope.btnGuardar = function(){
var datos = {
id: $scope.txtId,
imagen: $scope.getTheFiles
}
var apiUrl = 'http://tiendawebapi.azurewebsites.net/api/marcas/';
$http.post(apiUrl, JSON.stringify(datos)).then(function(response){
if (response.statusText == Created){
$scope.msgGuardar = "Marca Guardada";
}
}, function(error){
$scope.msgGuardar = "Ocurrio un error " + error.statusText;
});
};
});

AngularJS element ID loaded with ng-include not found in index.html?

So the flow is I visit / then the script load main.html which include header.html then inject to ng-view in index.html
Here is the detail
My index.html
<!DOCTYPE HTML>
<html>
<head>
<title>Koupon - Index</title>
<!-- meta info -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="keywords" content="Koupon HTML5 Template" />
<meta name="description" content="Koupon - Premiun HTML5 Template for Coupons Website">
<meta name="author" content="Dark Cyber" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Google fonts -->
<!-- <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,600' rel='stylesheet' type='text/css'> -->
<!-- <link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'> -->
<!-- Bootstrap styles -->
<link rel="stylesheet" href="css/boostrap.css">
<link rel="stylesheet" href="css/boostrap_responsive.css">
<!-- Font Awesome styles (icons) -->
<link rel="stylesheet" href="css/font_awesome.css">
<!-- Main Template styles -->
<link rel="stylesheet" href="css/styles.css">
<!-- IE 8 Fallback -->
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->
<!-- Your custom styles (blank file) -->
<link rel="stylesheet" href="css/mystyles.css">
<!-- Backend Style -->
<!-- End Backend Style -->
</head>
<body ng-app="rentalkika">
<!-- //// START PAGE CONTENT -->
<div ng-view>
</div>
<!-- END PAGE CONTENT /// -->
<!-- Scripts queries -->
<script src="js/jquery.js"></script>
<script src="js/boostrap.min.js"></script>
<script src="js/nivo_slider.min.js"></script>
<script src="js/countdown.min.js"></script>
<script src="js/magnific.min.js"></script>
<script src="js/tweet.min.js"></script>
<!--
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="js/gmap3.min.js"></script>
-->
<script src="js/wilto_slider.min.js"></script>
<script src="js/mediaelement.min.js"></script>
<script src="js/fitvids.min.js"></script>
<script src="js/mail.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular-route.js"></script>
<script src="js/ng-file-upload-shim.js"></script>
<script src="js/ng-file-upload.js"></script>
<script src="js/app.js"></script>
<script src="js/flexnav.min.js"></script>
<!-- Custom scripts -->
<script src="js/custom.js"></script>
<script type="text/javascript" >
if($('#something').length){
alert('something found');
//I want to init plugin with #something here
}else{
alert('something not found');
}
</script>
<!-- Backend JS -->
<!-- End Backend JS -->
</body>
</html>
app.js
$routeProvider
.when('/', {
templateUrl : 'pages/main.html',
title: "Home"
})
main.html
<div ng-include="'header.html'"></div>
<!-- TOP AREA -->
<div class="top-area">
<!-- START BOOTSTRAP CAROUSEL -->
<div id="my-carousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="img/1200x480.png" alt="Image Alternative text" title="Old No7" />
<div class="carousel-caption countdown-caption">
<h3>Jack Daniels Huge Pack</h3>
<!-- COUNTDOWN -->
<div data-countdown="Aug 25, 2013 5:30:00" class="countdown"></div>Save 70%
</div>
</div>
<div class="item">
<img src="img/1200x480.png" alt="Image Alternative text" title="iPhone 5 iPad mini iPad 3" />
<div class="carousel-caption countdown-caption">
<h3>Apple Big Deal</h3>
<!-- COUNTDOWN -->
<div data-countdown="Aug 30, 2013 10:45:00" class="countdown"></div>Save 50%
</div>
</div>
<div class="item">
<img src="img/1200x480.png" alt="Image Alternative text" title="the best mode of transport here in maldives" />
<div class="carousel-caption countdown-caption">
<h3>Finshing in Maldives</h3>
<!-- COUNTDOWN -->
<div data-countdown="Sep 2, 2013 22:00:00" class="countdown"></div>Save 30%
</div>
</div>
</div>
<a class="carousel-control left" href="#my-carousel" data-slide="prev"></a>
<a class="carousel-control right" href="#my-carousel" data-slide="next"></a>
</div>
<!-- END BOOTSTRAP CAROUSEL -->
</div>
<!-- END TOP AREA -->
<div ng-include="'footer.html'"></div>
header.html
<!-- //////////////////////////////////
//////////////MAIN HEADER/////////////
////////////////////////////////////-->
<div id="something">
</div>
<header class="main">
<div class="container">
<div class="row">
<div class="span2">
<a href="index.html">
<img src="img/logo-small.png" alt="logo" title="logo" class="logo">
</a>
</div>
<div class="span8">
<!-- MAIN NAVIGATION -->
<div class="flexnav-menu-button" id="flexnav-menu-button">Menu</div>
<nav>
<ul class="nav nav-pills flexnav" id="flexnav" data-breakpoint="800">
<li class="active">Home
</li>
<li>Layanan
<ul>
<li>Sewa Mobil
</li>
<li>Shuttle
</li>
</ul>
</li>
<li>Paket Wisata
<ul>
<li>xxx</li>
<li>bbb</li>
</ul>
</li>
<li>Blog
</li>
<li>FAQ
</li>
<li>Tertarik menjadi mitra kami?</li>
<li>Contact
</li>
</ul>
</nav>
<!-- END MAIN NAVIGATION -->
</div>
<div class="span2">
<!-- LOGIN REGISTER LINKS -->
<ul class="login-register" ng-controller="LoginController">
<li ng-hide="loggedIn"><a class="popup-text" href="#login-dialog" data-effect="mfp-move-from-top"><i class="icon-signin"></i>Sign in</a>
</li>
<li ng-show="loggedIn"><i class="icon-signout"></i>Sign out
</li>
<li><i class="icon-edit"></i>Sign up
</li>
<!-- LOGIN REGISTER LINKS CONTENT -->
<div id="login-dialog" class="mfp-with-anim mfp-hide mfp-dialog clearfix">
<i class="icon-signin dialog-icon"></i>
<h3>Member Login</h3>
<h5>Welcome back, friend. Login to get started</h5>
<div class="row-fluid">
<form class="dialog-form" ng-submit="handleLogin()" >
<label>Username</label>
<input type="text" placeholder="yourUsername" ng-model="login.username" class="span12">
<label>Password</label>
<input type="password" placeholder="My secret password" ng-model="login.password" class="span12">
<label class="checkbox">
<input type="checkbox">Remember me
</label>
<div class="control-group error" ng-show="error">
<span class="error help-block">
{{ error }}
</span>
</div>
<input type="submit" value="Sign in" class="btn btn-primary">
<button ng-click="FBLogin()" class="btn btn-primary">Login with Facebook</button>
</form>
</div>
<!--
<ul class="dialog-alt-links">
<li><a class="popup-text" href="#register-dialog" data-effect="mfp-zoom-out">Not member yet</a>
</li>
<li><a class="popup-text" href="#password-recover-dialog" data-effect="mfp-zoom-out">Forgot password</a>
</li>
</ul>
-->
</div>
</ul>
</div>
</div>
</div>
</header>
<div id="password-recover-dialog" class="mfp-with-anim mfp-hide mfp-dialog clearfix">
<i class="icon-retweet dialog-icon"></i>
<h3>Password Recovery</h3>
<h5>Fortgot your password? Don't worry we can deal with it</h5>
<div class="row-fluid">
<form class="dialog-form">
<label>E-mail</label>
<input type="text" placeholder="email#domain.com" class="span12">
<input type="submit" value="Request new password" class="btn btn-primary">
</form>
</div>
</div>
<!-- END LOGIN REGISTER LINKS CONTENT -->
<!-- //////////////////////////////////
//////////////END MAIN HEADER//////////
////////////////////////////////////-->
The above script will alert something not found but if I put <div id="something"></div> directly to index.html the script will alert something found
What I need is <div id="something"></div> in header.html then I init plugin with #something in index.html
Is something wrong with my structure or code?
<div id="something" ng-controller="SomethingController">
</div>
then in your SomethingController
$("#something").initPlugin();

AngularJS not working

I am using AngularJS for the very first time and I am writing down the HTML script of the page over here:
<!DOCTYPE html>
<html>
<head>
<title>_LayoutPersonal</title>
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-3.1.0.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui-1.12.0.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.min.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script>
alert("india");
function questionController($scope) {
$scope.queList = ['a', 'b'];
alert("India");
}
var queApp = angular.module("queApp", []);
queApp.controller("queCtrl", questionController);
</script>
</head>
<body>
<!-- Always on top: Position Fixed-->
<header>
Stack Overflow
</header>
<div class="subheader">
<div style="float:left;"><h1>Stack Overflow</h1></div>
<div class="sidebar3">
<input type="button" id="btnQuestions" value="Questions" onclick="location.href='/Question/Show'"/>
<input type="button" id="btnJobs" value="Jobs" onclick="location.href='/Question/Show'"/>
<input type="button" id="btnTags" value="Tags" onclick="location.href='/Question/Show'"/>
<input type="button" id="btnUsers" value="Users" onclick="location.href='/Question/Users'"/>
<input type="button" id="btnBadges" value="Badges" onclick="location.href='/Question/Badges'"/>
<input type="button" id="btnAskQuestion" value="Ask Question" onclick="location.href='/Question/Ask'"/>
Ask Question
</div>
</div>
<!-- Fixed size after header-->
<div class="content">
<!-- Scrollable div with main content -->
<div id="scrollable2">
<h3>Questions</h3>
<a href="/Question/Show/1">
<div class="questionlistitem">
<label for="Model_binding_MVC_3_not_working_as_expected">Model binding MVC 3 not working as expected</label>
<label for="">9/14/2016 12:00:00 AM</label>
</div>
</a>
<a href="/Question/Show/2">
<div class="questionlistitem">
<label for="Business_logic_layer_in_ASP_NET_MVC_-_Architecture">Business logic layer in ASP.NET MVC - Architecture</label>
<label for="">9/10/2016 12:00:00 AM</label>
</div>
</a>
<div ng-controller="queCtrl">
<div ng-repeat="question in queList">
{{question}}
</div>
</div>
</div>
<!-- Always on top. Fixed position, fixed width, relative to content width -->
<div class="sidebar2">
<div class="metapost">
<h4 class="headertitle">Hot Meta Post</h4>
<div class="sidebarinnerdiv">Is it useful to edit a question I will vote to close? </div>
<div class="sidebarinnerdiv">Rewriting a Waffle question</div>
</div>
<div class="networkquestions">
<h4>Hot Network Questions</h4>
<div class="sidebarinnerdiv">How to pronounce the English alphabet? (A, B, C, ...)</div>
<div class="sidebarinnerdiv">Why does the Black Lives Matter movement organize protests while the incident they're protesting is still under investigation?</div>
</div>
</div>
</div>
<!-- Always at the end of the page -->
<footer>
Copyright 2016, Stack Overflow
</footer>
</body>
</html>
It is not working and I am seeing {{question}} on the page. I am not able to trace down the source of the error. Please help me make my page work.
You forgot to add ng-app="queApp"
function questionController($scope) {
$scope.queList = ['a', 'b'];
}
var queApp = angular.module("queApp", []);
queApp.controller("queCtrl", questionController);
<!DOCTYPE html>
<html ng-app="queApp">
<head>
<title>_LayoutPersonal</title>
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-3.1.0.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui-1.12.0.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.min.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
</head>
<body>
<!-- Always on top: Position Fixed-->
<header>
Stack Overflow
</header>
<div class="subheader">
<div style="float:left;">
<h1>Stack Overflow</h1>
</div>
<div class="sidebar3">
<input type="button" id="btnQuestions" value="Questions" onclick="location.href='/Question/Show'" />
<input type="button" id="btnJobs" value="Jobs" onclick="location.href='/Question/Show'" />
<input type="button" id="btnTags" value="Tags" onclick="location.href='/Question/Show'" />
<input type="button" id="btnUsers" value="Users" onclick="location.href='/Question/Users'" />
<input type="button" id="btnBadges" value="Badges" onclick="location.href='/Question/Badges'" />
<input type="button" id="btnAskQuestion" value="Ask Question" onclick="location.href='/Question/Ask'" />
Ask Question
</div>
</div>
<!-- Fixed size after header-->
<div class="content">
<!-- Scrollable div with main content -->
<div id="scrollable2">
<h3>Questions</h3>
<a href="/Question/Show/1">
<div class="questionlistitem">
<label for="Model_binding_MVC_3_not_working_as_expected">Model binding MVC 3 not working as expected</label>
<label for="">9/14/2016 12:00:00 AM</label>
</div>
</a>
<a href="/Question/Show/2">
<div class="questionlistitem">
<label for="Business_logic_layer_in_ASP_NET_MVC_-_Architecture">Business logic layer in ASP.NET MVC - Architecture</label>
<label for="">9/10/2016 12:00:00 AM</label>
</div>
</a>
<div ng-controller="queCtrl">
<div ng-repeat="question in queList">
{{question}}
</div>
</div>
First of all you need 'ng-app="queApp"' in order to use AngularJS (Basics AngularJS)

Kendo ui mobile splitview navigation issue

I try to set up a sample for an universal app. Currently I'm stuck with navigation inside the splitview. The console logs an error saying that the links "#rightOne" and "#rightTwo" are not found. Here is my code (testet in kendo ui dojo). The code is adjusted to allways show the tablet code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="http://cdn.kendostatic.com/2014.1.416/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.1.416/styles/kendo.default.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.1.416/styles/kendo.mobile.all.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2014.1.416/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.1.416/js/kendo.all.min.js"></script>
<style>
html, body, #phoneApp {
height: 100%;
}
</style>
</head>
<body>
<div id="tabletApp" style="display:none;">
<div data-role="splitview">
<div data-role="pane" id="left" data-layout="leftLayout">
<div data-role="view">
One
Two
</div>
<div data-role="layout" data-id="leftLayout">
<div data-role="header">
<div data-role="navbar">
TEST APP
</div>
</div>
</div>
</div>
<div data-role="pane" id="right" data-layout="rightLayout">
<div data-role="view" id="rightOne">
One
</div>
<div data-role="view" id="rightTwo">
Two
</div>
<div data-role="layout" data-id="rightLayout">
<div data-role="header">
<div data-role="navbar">
</div>
</div>
</div>
</div>
</div>
</div>
<div id="phoneApp" style="display:none;">
<div data-role="view">
<h1>Phone Home</h1>
</div>
<div data-role="view" id="about">
<h1>Phone About</h1>
</div>
<div data-role="layout" data-id="phoneDefault">
<div data-role="header">
<div data-role="navbar">
Phone App
</div>
</div>
<!--Content-->
<div data-role="footer">
<div data-role="tabstrip">
Home
About
</div>
</div>
</div>
</div>
<script>
$(function() {
var app,
//Must be mobile and tablet
isTablet = kendo.support.mobileOS && kendo.support.mobileOS.tablet,
appElement = null,
appLayout = null;
console.log("mobileOS Info/isTablet", kendo.support.mobileOS, isTablet);
appElement = $("#tabletApp");
appLayout = (isTablet) ? null : "phoneDefault";
console.log(appElement);
app = new kendo.mobile.Application(appElement, {
transition: 'slide'
});
//Adjust visibility of proper app container
appElement.show();
});
</script>
</body>
</html>
If you turn your 2 links into Button widgets with data-role="button" then is works.
One
Two
I'm not really sure why this changes the internal routing in Kendo, but it looks like when it is a plain <a> then it tries to actually navigate instead of load a view element from the DOM.

Resources