更新后路由器停止工作

时间:2017-12-04 18:23:28

标签: html angularjs

我曾经使附加的代码运行得很好,但随后更新导致它停止工作。我无法做出调整,所以希望有人在这里经历过。 HTML之后的最后一个块只是包含js文件的智能代码。我得到的网址是:mySite.com/policies#!/#refund 它不会加载任何东西。如果我手动删除第二个#来使它/策略#!/退款它确实有效。

这是js文件:

var app = angular.module('myApp', ['ngRoute', 'ui.bootstrap', 'dialogs.main', 
'summernote', 'angular-loading-bar', 'ngAnimate', 'fiestah.money', 'ui.ace', 
'ui.select', 'ngCart']);
app.config(function ($routeProvider, $locationProvider) {
$routeProvider
    .when('/', {
        templateUrl: '/templates/main-app/policy/policy-reviews.tpl',
        controller: 'mainCtrl'
    })
    .when('/reviews', {
        templateUrl: '/templates/main-app/policy/policy-reviews.tpl',
        controller: 'mainCtrl'
    })
    .when('/currency', {
        templateUrl: '/templates/main-app/policy/policy-currency.tpl',
        controller: 'mainCtrl'
    })
    .when('/refund', {
        templateUrl: '/templates/main-app/policy/policy-refund.tpl',
        controller: 'mainCtrl'
    });

});     app.controller('mainCtrl',函数($ scope,$ rootScope,$ filter,$ http,$ location,dialogs){     console.log(“在ctrl中”); });

这是模板:

<div ng-controller="mainCtrl">
<div class="act-dash">
    <nav class="navbar-default content-header blue" role="navigation" style="position:relative;">
        <!-- We use the fluid option here to avoid overriding the fixed width of a normal container within the narrow content columns. -->
        <div id="admin-collapse" class="pad-left-fix" style="bottom:0px;">
            <div class="container"><h1>Terms and Policies</h1></div>
            <ul class="nav navbar-nav" style="position:relative; bottom:0px">
                <li><a href="#reviews"><span class="glyphicon glyphicon-eye-open"> </span>Comments and Reviews</a></li>
                <li><a href="#currency"><span class="glyphicon glyphicon-usd"> </span>Currency Conversion</a></li>
                <li><a href="#refund"><span class="glyphicon glyphicon-usd"> </span>Refund Policy</a></li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </nav>
    <div class="content narrow-content margin-fix">
        <div class="row margin-fix margin-bottom-fix div-table" style="width:100%;">
            <div class="col-md-12 pad-left-fix pad-right-fix div-table-cell">
                <div style="text-align: left;">
                    <div id="main">
                        <!-- angular templating -->
                        <!-- this is where content will be injected -->
                        <div ng-view>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{assign var="extra_js" scope="global" value="
    <script type=\"text/javascript\" src=\"/js/angular-apps/policy.js\">
</script>

“}

1 个答案:

答案 0 :(得分:2)

  

您可以在app.config中添加以下代码行,如下所示   $ routeProvider并查看它是否可行。运行前请清除缓存   和浏览器上的coockies。

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  ScrollView
} from 'react-native';

export default class App extends Component {
  render() {
    return (
      <ScrollView
        style={{ backgroundColor: '#edf2f9'}}
        contentContainerStyle={styles.container}
      >
        <View style={styles.card}>
          <View style={styles.header}>
            <View style={styles.iconTitle}>
              <View style={styles.icon} />
              <Text>Hello world</Text>
            </View>
            <View style={styles.buttonWrap}>
              <View style={styles.button} />
              <View style={styles.button} />
              <View style={styles.button} />
            </View>
          </View>
          <View>
            <Text>
            Some other content...
            </Text>
          </View>
        </View>

        <View style={styles.card}>
          <View style={styles.header}>
            <View style={styles.iconTitle}>
              <View style={styles.icon} />
              <Text style={styles.title}>
                Hello world this is some really long title right here, that
                goes on and on and on. And then some!
              </Text>
            </View>
            <View style={styles.buttonWrap}>
              <View style={styles.button} />
              <View style={styles.button} />
              <View style={styles.button} />
            </View>
          </View>
          <View>
            <Text>
              Some other content...
            </Text>
          </View>
        </View>
      </ScrollView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#edf2f9',
  },
  card: {
    backgroundColor: 'white',
    height: 200,
    width: 320,
    shadowColor: 'black',
    shadowOpacity: 0.25,
    shadowOffset: {x: 10, y: 10},
    padding: 10,
    marginTop: 10,
  },
  header: {
    borderBottomWidth: 0.5,
    borderBottomColor: 'lightgrey',
    flexDirection: 'row',
    marginBottom: 10,
    justifyContent: 'space-between',
  },
  iconTitle:{
    flexDirection: 'row',
    flex: 1,
    marginBottom: 10,
  },
  icon: {
    height: 24,
    width: 24,
    backgroundColor: 'black',
    marginRight: 5,
  },
  title: {
    flex: 1,
  },
  buttonWrap: {
    flexDirection: 'row',
  },
  button: {
    height: 24,
    width: 24,
    backgroundColor: 'red',
    marginLeft: 5,
  }
});