var shop = angular.module("shopStore",['ngRoute']);
shop.controller('productsList',function($scope){
$scope.stock = [
{type: "motherboard",model: 'AM1I',company: 'MSI'},
{type: "motherboard",model: ' A88XM-PLUS/CSM FM2', company: 'MSI'}
];
});
shop.config(function ($routeProvider){
$routeProvider.
when('/', {
controller: 'productsList',
templateUrl: "partials/home.html"
}).
when('/products', {
controller: 'productsList',
templateUrl: "partials/products.html"
}).
when('/cart', {
controller: 'productsList',
templateUrl: 'partials/cart.html'
})
});
var x = document.querySelector('#elem');
console.log(x);
// Doesn't work, it doesn't work with all the others.
the products arrangement doesn't matter, I have another file with all the information, it is just to let you know the structure
<b><div id="elem"></div></b>
<div id="stock" ng-repeat="products in stock" ondrag="part.drag(this)">
<div class="image">
<a href={{products.link}}>
<img ng-src={{products.picture}} title{{products.company}} width="70px">
</a>
</div>
<div class="type">{{products.type}}</div>
<div class="company">{{products.company}}</div>
<div class="model">{{products.model}}</div>
<div class="button1"><button ngclick="add(product)">Add</button></div>
<div class="buttonInput">
<input type="button" onclick='Shoping.remove(this)' value="X">
</div>
</div>
When I try to call any of the elements in the partials html with document by ID or querySelector it doesn't work; what should I write to get the element from a ng-view template?
js在顶部,模板html在底部,用于常规使用,而不是angular js